The Security package provides encryption, decryption and hashing functions. The major functionalities offered in the Security Package are the following:

  • Encrypt(), EncryptBytes() and Decrypt(), DecryptBytes() provide crypting functionality.
  • Hash() provides a set of one-way, secure hashes.

  • Some definitions of the modes of the ciphers listed below:

    Electronic codebook (ECB)
    Cipher-block chaining (CBC)
    Propagating cipher-block chaining (PCBC)
    Cipher feedback (CFB)
    Output feedback (OFB)

    For more information please see this link at wikipedia.

    Examples:

    String data = "This is my data"
    String key = "TheseAreNotTheDroids"

    String enc = Security.Encrypt ( data, key, Security.DES_EDE3_CBC )
    String dec = Security.Decrypt ( enc, key, Security.DES_EDE3_CBC )
    Bytes benc = Security.EncryptBytes ( data, key, Security.DES_EDE3_CBC )
    dec = Security.DecryptBytes ( benc, key, Security.DES_EDE3_CBC )

    String hash = Security.Hash ( data, Security.MD5 )
    echo ( "MD5 hash = ", hash )

    MD5 hash = bf27d031ffc5410071c553be3d93020b

    Class Attributes Index

    Encryption/Decryption Types

    RC2 family

     o RC2_ECB
    128 bit RC2 in ECB mode.
     o RC2_CBC
    128 bit RC2 in CBC mode.
     o RC2_CFB64
    128 bit RC2 in CFB mode.
     o RC2_OFB64
    128 bit RC2 in OFB mode.
     o RC2_40_CBC
    40 bit RC2 in CBC mode.
     o RC2_64_CBC
    64 bit RC2 in CBC mode.

    RC4 family

     o RC4
    128 bit RC4.
     o RC4_40
    40 bit RC4.

    DES family

     o DES_ECB
    56 bit DES in ECB mode.
     o DES_CBC
    56 bit DES in CBC mode.
     o DES_CFB8
    56 bit DES in 8 bit CFB mode.
     o DES_CFB64
    56 bit DES in 64 bit CFB mode.
     o DES_OFB64
    56 bit DES in 64 bit OFB mode.
     o DES_EDE_ECB
    112 bit 2 key triple DES in ECB mode.
     o DES_EDE_CBC
    112 bit 2 key triple DES in ECB mode.
     o DES_EDE_CFB64
    112 bit 2 key triple DES in 64 bit CFB mode.
     o DES_EDE_OFB64
    112 bit 2 key triple DES in 64 bit OFB mode.
     o DESX_CBC
    56 bit DESX in CBC mode.

    TripleDES family

     o DES_EDE3_ECB
    168 bit 3DES in ECB mode.
     o DES_EDE3_CBC
    168 bit 3DES in CBC mode.
     o DES_EDE3_CFB64
    168 bit 3DES in 64 bit CFB mode.
     o DES_EDE3_OFB64
    168 bit 3DES in 64 bit OFB mode.

    Blowfish family

     o BF_ECB
    128 bit blowfish in ECB mode.
     o BF_CBC
    128 bit blowfish in CBC mode.
     o BF_CFB64
    128 bit blowfish in 64 bit CFB mode.
     o BF_OFB64
    128 bit blowfish in 64 bit OFB mode.

    CAST5 Family

     o CAST5_ECB
    128 bit CAST5 in ECB mode.
     o CAST5_CBC
    128 bit CAST5 in CBC mode.
     o CAST5_CFB64
    128 bit CAST5 in 64 bit CFB mode.
     o CAST5_OFB64
    128 bit CAST5 in 64 bit OFB mode.

    AES/Rijndael Family

     o AES_128_ECB
    128 bit AES in ECB mode.
     o AES_128_CBC
    128 bit AES in CBC mode.
     o AES_128_OFB128
    128 bit AES in 128 bit OFB mode.
     o AES_128_CFB128
    128 bit AES in 128 bit CFB mode.
     o AES_192_ECB
    192 bit AES in ECB mode.
     o AES_192_CBC
    192 bit AES in CBC mode.
     o AES_192_OFB128
    192 bit AES in 128 bit OFB mode.
     o AES_192_CFB128
    192 bit AES in 128 bit CFB mode.
     o AES_256_ECB
    256 bit AES in ECB mode.
     o AES_256_CBC
    256 bit AES in CBC mode.
     o AES_256_OFB128
    256 bit AES in 128 OFB mode.
     o AES_256_CFB128
    256 bit AES in 128 CFB mode.
     o AES_128_CFB8
    128 bit AES in 8 bit CFB mode.
     o AES_192_CFB8
    192 bit AES in 8 bit CFB mode.
     o AES_256_CFB8
    256 bit AES in 8 bit CFB mode.

    Secure Hash Types

     o MD2
    128 bit MD2 hash.
     o MD4
    128 bit MD4 hash.
     o MD5
    128 bit MD5 hash.
     o SHA
    160 bit SHA-0 hash.
     o SHA1
    160 bit SHA-1 hash.
     o SHA224
    224 bit SHA-2 hash.
     o SHA256
    256 bit SHA-2 hash.
     o SHA384
    384 bit SHA-2 hash.
     o SHA512
    512 bit SHA-2 hash.
     o RIPEMD160
    160 bit RIPEMD hash.

    Class Methods Index

     o String Encrypt( String value, String key, Integer encryptionType  )
    Encrypts 'value' with a key generated with 'key' using the encryptionType constant ( see above for constants ). Returns a base64 encoded string of bytes

     o String Decrypt( String value, String key, Integer encryptionType  )
    Decrypts 'value' with a key generated with 'key' using the encryptionType constant ( see above for constants ). Value should a base64 encoded string of bytes

     o Bytes EncryptBytes( String value, String key, Integer encryptionType  )
    Encrypts the String 'value' with a key generated with 'key' using the encryptionType constant ( see above for constants ). Returns a Bytes object

     o String DecryptBytes( Bytes value, String key, Integer encryptionType  )
    Decrypts the Bytes 'value' with a key generated with 'key' using the encryptionType constant ( see above for constants ). Returns a string.

     o String Hash( String value, Integer hashType  )
    Hashes 'value' with the algorithm specified, returning a hex-encoded string.

    Class Methods

     o Encrypt
     String Encrypt(
                String value,
                String key,
                Integer encryptionType,
    

    Encrypt value with key using encryptionType

    Parameters:
    value  -  String containing the value to be encrypted.
    key  -  String containing the text used to generate the key to encrypt the value with.
    encryptionType  -  Type of encryption to use
    Returns:
    A base64 encoded string of the encrypted value.

     o Decrypt
     String Decrypt(
                String value,
                String key,
                Integer encryptionType,
    

    Decrypts value with key using encryptionType

    Parameters:
    value  -  String containing the base64 encoded value to be decrypted.
    key  -  String containing the text used to generate the key to decrypt the value with.
    encryptionType  -  Type of encryption to use
    Returns:
    A hex encoded string of the decrypted value.

     o EncryptBytes
     Bytes EncryptBytes(
                String value,
                String key,
                Integer encryptionType,
    

    Encrypts value with key using encryptionType

    Parameters:
    value  -  String containing the value to be encrypted.
    key  -  String containing the text used to generate the key to encrypt the value with.
    encryptionType  -  Type of encryption to use
    Returns:
    A Bytes object of the encrypted value.

     o DecryptBytes
     String DecryptBytes(
                Bytes value,
                String key,
                Integer encryptionType,
    

    Decrypts value with key using encryptionType

    Parameters:
    value  -  Bytes containing the value to be decrypted.
    key  -  String containing the text used to generate the key to decrypt the value with.
    encryptionType  -  Type of encryption to use
    Returns:
    A String object of the decrypted value.

     o Hash
     String Hash(
                String value,
                Integer hashType,
    

    Hash value using hashType

    Parameters:
    value  -  String containing the value to be decrypted.
    hashType  -  Type of hash algorithm to use
    Returns:
    A hex encoded string of the hash.