(PureBasic) Example: Crypt2.EncryptEncoded method
Demonstrates how to call the EncryptEncoded method.
IncludeFile "CkCrypt2.pb"
Procedure ChilkatExample()
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")
; Encrypt the bytes 0x00, 0x01, 0x02, ... 0x0A
; and return the encrypted bytes using the lowercase hex encoding.
CkCrypt2::setCkEncodingMode(crypt, "hex_lower")
encrypted.s = CkCrypt2::ckEncryptEncoded(crypt,"000102030405060708090a")
Debug encrypted
; Output:
; 9da2ae71a5378487114b430e5e230378
decrypted.s = CkCrypt2::ckDecryptEncoded(crypt,encrypted)
Debug decrypted
; Output:
; 000102030405060708090a
CkCrypt2::ckDispose(crypt)
ProcedureReturn
EndProcedure
|