(DataFlex) MD5 Hash a String (such as a password string)
Demonstrates how to MD5 hash a string to get MD5 hash in hex encoded string representation. (The MD5 hash is 16 bytes, and therefore a hex encoded MD5 hash would be 32 chars.)
Use ChilkatAx-win32.pkg
Procedure Test
String sPassword
Handle hoCrypt
String sMd5Hex
Move "myPassword" To sPassword
Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt
If (Not(IsComObjectCreated(hoCrypt))) Begin
Send CreateComObject of hoCrypt
End
Set ComHashAlgorithm Of hoCrypt To "md5"
Set ComEncodingMode Of hoCrypt To "hex"
Get ComHashStringENC Of hoCrypt sPassword To sMd5Hex
Showln "MD5 hash (as a hex string) = " sMd5Hex
// The hex string will be uppercase. Your application
// can easily convert it to lowercase if desired via non-Chilkat means.
End_Procedure
|