-
Notifications
You must be signed in to change notification settings - Fork 2
/
PBKDF2.asp
89 lines (56 loc) · 2.51 KB
/
PBKDF2.asp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<%
' INSTALLATION:
'************************************************************************
' Uses CryptoHelper (a Standalone password hasher for ASP.NET Core using a PBKDF2 implementation) by henkmollema
' https://github.com/henkmollema/CryptoHelper
' Make sure you have the lastest .NET Framework installed (tested on .NET Framework 4.7.2)
' Open IIS, go to the applicaton pools and open the application pool being used by your
' website. Check the .NET CRL version
' E.g: v4.0.30319
' Navigate to the CRL folder
' E.g: C:\Windows\Microsoft.NET\Framework64\v4.0.30319
' Copy over:
' ClassicASP.PBKDF2.dll,
' Microsoft.AspNetCore.Cryptography.Internal.dll,
' Microsoft.AspNetCore.Cryptography.KeyDerivation.dll
' Run CMD as administrator
' Change the directory to your CRL folder
' E.g: cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
' Run the following command: RegAsm ClassicASP.PBKDF2.dll /tlb /codebase
' PBKDF2 IN VBSCRIPT:
'************************************************************************
' Defaults used by ClassicASP.PBKDF2 if none specified:
' PBKDF2_iterations = 10000
' PBKDF2_alg = sha1
' PBKDF2_saltBytes = 16 bytes
' PBKDF2_keyLength = 32 bytes
Const PBKDF2_iterations = 30000
Const PBKDF2_alg = "sha512" ' only sha1, sha256 and sha512 are supported
Const PBKDF2_saltBytes = 16
Const PBKDF2_keyLength = 32
function PBKDF2_hash(ByVal password)
Dim PBKDF2 : set PBKDF2 = server.CreateObject("ClassicASP.PBKDF2")
PBKDF2_hash = PBKDF2.hash(_
password,_
PBKDF2_iterations,_
PBKDF2_alg,_
PBKDF2_saltBytes,_
PBKDF2_keyLength)
set PBKDF2 = nothing
end function
function PBKDF2_verify(ByVal password, ByVal PBKDF2Hash)
Dim PBKDF2 : set PBKDF2 = server.CreateObject("ClassicASP.PBKDF2")
PBKDF2_verify = PBKDF2.verify(password,PBKDF2Hash)
set PBKDF2 = nothing
end function
Dim pb2_hash, start, testPassword
testPassword = "myPassword"
response.write "<p><b>Password:</b> " & testPassword & "</p>"
start = Timer()
pb2_hash = PBKDF2_hash(testPassword)
response.write "<p><b>PBKDF2 Hash:</b> " & pb2_hash & "</p>"
response.write "<p><b>Time to execute:</b> " & formatNumber(Timer()-start,4) & "s</p>"
start = Timer()
response.write "<p><b>PBKDF2 Verified:</b> " & PBKDF2_verify(testPassword,pb2_hash) & "</p>"
response.write "<p><b>Time to execute:</b> " & formatNumber(Timer()-start,4) & "s</p>"
%>