Skip to content

Instantly share code, notes, and snippets.

@blackskye-sx
Forked from ken-itakura/MD5.vb
Created March 30, 2020 19:23
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 blackskye-sx/5660c7fa20081f5b3847ca077a240a04 to your computer and use it in GitHub Desktop.
Save blackskye-sx/5660c7fa20081f5b3847ca077a240a04 to your computer and use it in GitHub Desktop.
Excel, Access VBA Function to create MD5 for text
Public Function MD5Hex(textString As String) As String   
Dim enc   
Dim textBytes() As Byte   
Dim bytes   
Dim outstr As String       
Set enc = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")   
textBytes = textString   
bytes = enc.ComputeHash_2((textBytes))   
For pos = 1 To LenB(bytes)       
outstr = outstr & LCase(Right("0" & Hex(AscB(MidB(bytes, pos, 1))), 2))   
Next   
MD5Hex = outstr   
Set enc = Nothing
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment