The SymmetricCrypt class provides basic symmetric encryption and decryption functionality.
// create a password entry dialog
const dialog = new PasswordEntryDialog();
dialog.setCaption("Encryption Example");
dialog.setMessage("Please enter text to encrypt:");
if (dialog.showDialog() === DialogResult.Ok) {
// encrypt the text with an encryption key and then decrypt it
const key = "ABCDEF";
const encrypted_text = SymmetricCrypt.encryptString(dialog.getText(), key);
const decrypted_text = SymmetricCrypt.decryptString(encrypted_text, key);
// show the key, the encrypted text, and the decrypted text
alert(`Encryption Key: ${key}\n` +
`Encrypted Text: ${encrypted_text}\n` +
`Decrypted Text: ${decrypted_text}`);
} else {
alert("Cancelled.");
} The decrypted string. If an error was encountered, an empty string is returned.
Decrypts a string which was encrypted with the SymmetricCrypt.encryptString method. In order to achieve successful decryption, the encryption key must be the same one used during encryption.
A salted, encrypted version of the string specified by the str parameter
Encrypts the string specified in the str parameter using the value specified in enckey as the encryption key. Both parameters should be strings. The input string may contain unicode characters. The resulting string is composed solely of ASCII characters, which makes it convenient for storage and transmission.