Skip to content

Instantly share code, notes, and snippets.

Last active October 15, 2018 12:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
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))
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