Asked By tlviewer
16-May-08 09:05 PM

hello,
see inline
I changed maybe four lines and added one function StrFromHex()
good luck,
Mark from tlviewer.org
strIpad = strIpad & Chr(arrIpad(i))
strOpad = strOpad & Chr(arrOpad(i))
hmac = sha1(strOpad & StringFromHex(sha1(strIpad & text)))
' add this helper function
Public Function StringFromHex(sText) 'As String
' 10-16-02 moved into the global module
Dim lCount 'As Long
Dim sChar 'As String
Dim sResult 'As String
Dim lLength 'As Long
Dim nJ 'As Long
lLength = Len(sText)
nJ = 1
For lCount = 1 To lLength Step 2
' Mid$(sResult, nJ, 1) = Chr(Val("&H" & Mid(sText, lCount, 2)))
sResult = sResult & Chr(Eval("&H" & Mid(sText, lCount, 2)))
nJ = nJ + 1
Next
StringFromHex = sResult
End Function
' to test rfc2204 vector use
mystr = StringFromHex("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b")
' mystr = ")!%rw{LH:[9b|!2A,an_n}]}aLnzTzbHdOIC%Y/?4bC&J[h-+hfM`Lj_>B[/7i#I"
mystr = mystr & String(64 - Len(mystr), vbNullStr)
'WSCript.echo sha1("The quick brown fox jumps over the lazy dog")
WScript.echo "hmac=",hmac(mystr,"Hi There")
' answer is b617318655057264e28bc0b6fb378c8ef146be00