Delphi DLL
Delphi DLL
Simple AES ECB Decryption
See more Encryption Examples
Decrypt 256-bit encrypted content.Chilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Crypt2;
...
procedure TForm1.Button1Click(Sender: TObject);
var
crypt: HCkCrypt2;
ct: PWideChar;
key: PWideChar;
pt: PWideChar;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
crypt := CkCrypt2_Create();
// Encrypted content (base64-encoded)
ct := 'd/95VziAnUNKkpXr3dJBFcQqAEDWlDkc7EU2jLkYPxmr6PpLRJlgHos+/Uy28CvJsmztQ3JkJAMukVoj46QJ/7RMuqLb31cSKd1ZvMzx9J9b6q0EkmPJcSfBhf2x7v5Qvq3lz1EIH7RM61cDGf+g9p4lt6FtU2MzCqtYD+Vr29voCn5WU1CnXmks64RrbyDA1DDHOx2deJ4Kn68+KoPM9tAw9kbf4HApL1nJYU3Mfzl+MnuHuB2kJpL5GqbuNvS+4QjxuwtNGuZEEY0gOS4RIvWl/XfkxtWHMkzsKy08AO792xDGer4rL4Q1NcfI/H2V';
// 256-bit AES key (literally the 32 us-ascii bytes of this string)
key := 'sQsPQYesBM5qEM5OSxicFatIiLM459Bu';
// Note: If your AES key is a string, and it's not clearly hex or base64, AND if the length of the string is the exact size of the AES key,
// then *literally* use the ascii chars as the AES key.
CkCrypt2_putCryptAlgorithm(crypt,'aes');
CkCrypt2_putCipherMode(crypt,'ecb');
CkCrypt2_putKeyLength(crypt,256);
// use the exact ascii bytes as the key.
CkCrypt2_SetEncodedKey(crypt,key,'ascii');
CkCrypt2_putEncodingMode(crypt,'base64');
pt := CkCrypt2__decryptStringENC(crypt,ct);
Memo1.Lines.Add(pt);
CkCrypt2_Dispose(crypt);
end;