(PureBasic) Example: Crypt2.DecryptStringENC method
Demonstrates how to call the DecryptStringENC method.
IncludeFile "CkCrypt2.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
crypt.i = CkCrypt2::ckCreate()
If crypt.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkCrypt2::setCkCryptAlgorithm(crypt, "aes")
CkCrypt2::setCkCipherMode(crypt, "cbc")
CkCrypt2::setCkKeyLength(crypt, 128)
CkCrypt2::ckSetEncodedKey(crypt,"000102030405060708090A0B0C0D0E0F","hex")
CkCrypt2::ckSetEncodedIV(crypt,"000102030405060708090A0B0C0D0E0F","hex")
CkCrypt2::setCkEncodingMode(crypt, "base64")
; Return the base64 encoded encrypted bytes
encodedEncrypted.s = CkCrypt2::ckEncryptStringENC(crypt,"Hello World!")
Debug "Encrypted: " + encodedEncrypted
; Output:
; Encrypted: qiq+IFhcjTkEIkZyf31V/g==
; Decrypt
originalText.s = CkCrypt2::ckDecryptStringENC(crypt,encodedEncrypted)
Debug "Decrypted: " + originalText
; Output:
; Decrypted: Hello World!
CkCrypt2::ckDispose(crypt)
ProcedureReturn
EndProcedure
|