Sample code for 30+ languages & platforms
Java

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    CkCrypt2 crypt = new CkCrypt2();

    CkBinData bdEncrypted = new CkBinData();
    CkStringBuilder sbPlainText = new CkStringBuilder();

    sbPlainText.Append("Text to be encrypted");

    //  ...
    //  Set the secret key ...
    //  Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
    //  Set the IV if needed ...
    //  ...

    crypt.put_Charset("utf-8");

    success = crypt.EncryptSb(sbPlainText,bdEncrypted);
    if (success == false) {
        System.out.println(crypt.lastErrorText());
        return;
        }
  }
}