Skip to content

Instantly share code, notes, and snippets.

@SethVandebrooke
Created October 19, 2018 20:33
Show Gist options
  • Save SethVandebrooke/ca3c21f6e4c9eeffae11dcc11f8a9370 to your computer and use it in GitHub Desktop.
Save SethVandebrooke/ca3c21f6e4c9eeffae11dcc11f8a9370 to your computer and use it in GitHub Desktop.
Classic ASP / VBScript SHA1 Hashing
function sha1HashString(str)
Dim hexStr, x, aBytes, sha1
aBytes = CreateObject("System.Text.UTF8Encoding").GetBytes_4(str)
set sha1 = CreateObject("System.Security.Cryptography.SHA1Managed")
sha1.Initialize()
aBytes = sha1.ComputeHash_2( (aBytes) )
for x=1 to lenb(aBytes)
hexStr= hex(ascb(midb( (aBytes),x,1)))
if len(hexStr)=1 then hexStr="0" & hexStr
sha1HashString=sha1HashString & hexStr
next
end function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment