PowerBuilder
PowerBuilder
Example: Crypt2.HashStringENC method
Demonstrates how to call the HashStringENC method.Chilkat PowerBuilder Downloads
integer li_rc
oleobject loo_Crypt
string s
string ls_HashStr
loo_Crypt = create oleobject
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
s = "får"
// The string "får" in utf-8 is composed of these bytes: 0x66 0xC3 0xA5 0x72
loo_Crypt.Charset = "utf-8"
loo_Crypt.EncodingMode = "hex_lower"
loo_Crypt.HashAlgorithm = "sha256"
// Get the hex string for the sha-256 hash of the utf-8 byte representation of the string
ls_HashStr = loo_Crypt.HashStringENC(s)
Write-Debug ls_HashStr
// Output:
// cb8f773dd592337ed7f928012a60f48e1efb357beeda124a54461410e216fece
destroy loo_Crypt