PowerBuilder
PowerBuilder
Example: Crypt2.DecryptStringENC method
Demonstrates how to call the DecryptStringENC method.Chilkat PowerBuilder Downloads
integer li_rc
oleobject loo_Crypt
string ls_EncodedEncrypted
string ls_OriginalText
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
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
loo_Crypt.CryptAlgorithm = "aes"
loo_Crypt.CipherMode = "cbc"
loo_Crypt.KeyLength = 128
loo_Crypt.SetEncodedKey("000102030405060708090A0B0C0D0E0F","hex")
loo_Crypt.SetEncodedIV("000102030405060708090A0B0C0D0E0F","hex")
loo_Crypt.EncodingMode = "base64"
// Return the base64 encoded encrypted bytes
ls_EncodedEncrypted = loo_Crypt.EncryptStringENC("Hello World!")
Write-Debug "Encrypted: " + ls_EncodedEncrypted
// Output:
// Encrypted: qiq+IFhcjTkEIkZyf31V/g==
// Decrypt
ls_OriginalText = loo_Crypt.DecryptStringENC(ls_EncodedEncrypted)
Write-Debug "Decrypted: " + ls_OriginalText
// Output:
// Decrypted: Hello World!
destroy loo_Crypt