One advantage to using the Chilkat Crypt component is that the identical API spans many programming languages: VB6, C#, VB.NET, Delphi, C++, FoxPro, ASP, Java, Ruby, Perl, Python, etc. (Actually, this applies to all the Chilkat components.)
A recent support email asked how to AES encrypt in Delphi, and decrypt in Java with both sides using the Chilkat encryption component. Here is the sample code:
Delphi Encryption Code
procedure TForm1.Button3Click(Sender: TObject);
var
encrypted: string;
begin
// ChilkatCrypt21 is an instance of ChilkatCrypt2
// that we dropped onto our form.
ChilkatCrypt21.UnlockComponent('test');
ChilkatCrypt21.CryptAlgorithm := 'rijndael';
ChilkatCrypt21.CipherMode := 'cbc';
ChilkatCrypt21.KeyLength := 128;
ChilkatCrypt21.EncodingMode := 'base64';
ChilkatCrypt21.SecretKey := ChilkatCrypt21.GenerateSecretKey('myPassword');
encrypted := ChilkatCrypt21.EncryptStringENC('This string is to be encrypted');
// Displays: cZLpHHyRILPmgdLF0ZauLK/2++YO/uBfPPkQl/WS9u0=
Edit1.Text := encrypted;
end;
Java Decryption Code
CkCrypt2 crypt = new CkCrypt2();
crypt.UnlockComponent("anything for 30-day trial");
crypt.put_CryptAlgorithm("aes");
crypt.put_CipherMode("cbc");
crypt.put_KeyLength(128);
crypt.put_EncodingMode("base64");
CkByteData secretKey = new CkByteData();
crypt.GenerateSecretKey("myPassword",secretKey);
crypt.put_SecretKey(secretKey);
CkString decrypted = new CkString();
crypt.DecryptStringENC("cZLpHHyRILPmgdLF0ZauLK/2++YO/uBfPPkQl/WS9u0=",decrypted);
// Displays: This string is to be encrypted
System.out.println(decrypted.getString());