SymmetricCrypt - Kirix Documentation

Developer Resources

SymmetricCrypt

Overview

The SymmetricCrypt class provides basic symmetric encryption and decryption functionality.

Methods

SymmetricCrypt.decryptString
Decrypts a string
SymmetricCrypt.encryptString
Encrypts a string

Example

// create a password entry dialog
var dialog = new PasswordEntryDialog;
dialog.setCaption("Encryption Example");
dialog.setMessage("Please enter text to encrypt:");

if (!dialog.showDialog())
{
    alert("Cancelled.");
}
else
{
    // encrypt the text with an encryption key and then decrypt it
    var key = "ABCDEF";
    var encrypted_text = SymmetricCrypt.encryptString(dialog.getText(), key);
    var decrypted_text = SymmetricCrypt.decryptString(encrypted_text, key);

    // show the key, the encrypted text, and the decrypted text
    var result;
    result += "Encryption Key: " + key + "\n";
    result += "Encrypted Text: " + encrypted_text + "\n";
    result += "Decrypted Text: " + decrypted_text;
    alert(result);
}

SymmetricCrypt.decryptString

static function SymmetricCrypt.encryptString(encstr : String, enckey : String) : String

Returns

The decrypted string. If an error was encountered, an empty string is returned.

Description

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.

SymmetricCrypt.encryptString

static function SymmetricCrypt.encryptString(str : String, enckey : String) : String

Returns

A salted, encrypted version of the string specified by the str parameter

Description

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.