(PowerBuilder) 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.)
integer li_rc
string ls_Password
oleobject loo_Crypt
string ls_Md5Hex
ls_Password = "myPassword"
loo_Crypt = create oleobject
// Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0
li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2")
if li_rc < 0 then
destroy loo_Crypt
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Crypt.HashAlgorithm = "md5"
loo_Crypt.EncodingMode = "hex"
ls_Md5Hex = loo_Crypt.HashStringENC(ls_Password)
Write-Debug "MD5 hash (as a hex string) = " + ls_Md5Hex
// The hex string will be uppercase. Your application
// can easily convert it to lowercase if desired via non-Chilkat means.
destroy loo_Crypt
|