Skip to content

Instantly share code, notes, and snippets.

@LNow
Last active October 15, 2018 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LNow/8823962 to your computer and use it in GitHub Desktop.
Save LNow/8823962 to your computer and use it in GitHub Desktop.
Public Function SHA1Hash(content As String) As String
Dim asc As Object
Set asc = CreateObject("System.Text.UTF8Encoding")
Dim enc As Object
Set enc = CreateObject("System.Security.Cryptography.SHA1CryptoServiceProvider")
Dim bytes() As Byte
bytes = asc.GetBytes_4(content)
bytes = enc.ComputeHash_2((bytes))
Dim pos As Long
For pos = 0 To UBound(bytes)
SHA1Hash = SHA1Hash & LCase(Right("0" & Hex(AscB(MidB(bytes, pos + 1, 1))), 2))
Next
Set asc = Nothing
Set enc = Nothing
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment