Java
Chilkat2 Java
Example: Crypt2.EncryptSb method
Demonstrates how to call the EncryptSb method.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.BinData;
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Crypt2;
import com.chilkatsoft.chilkat2.StringBuilder;
public class ChilkatExample {
public static void main(String[] args) {
Crypt2 crypt = new Crypt2();
BinData bdEncrypted = new BinData();
StringBuilder sbPlainText = new StringBuilder();
sbPlainText.append("Text to be encrypted");
// ...
// Set the secret key ...
// Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
// Set the IV if needed ...
// ...
crypt.setCharset("utf-8");
try {
crypt.encryptSb(sbPlainText, bdEncrypted);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
}
}