Last active
December 2, 2019 22:51
-
-
Save yovchev/892675f96f04bc82c005160b92e4f899 to your computer and use it in GitHub Desktop.
Excel, Access VBA Function to create MD5 from text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Function MD5Hex(textString As String) As String | |
Dim enc | |
Dim textBytes() As Byte | |
Dim bytes | |
Dim oUTF8 | |
Dim outstr As String | |
Set oUTF8 = CreateObject("System.Text.UTF8Encoding") | |
Set enc = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider") | |
textBytes = oUTF8.GetBytes_4(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