Enables the encryption and decryption of text using a symmetrical algorithm (DES, Rijndael, TripleDES), using CBC mode (Cipher Block Chaining).
The Create method allows us to specify the algorithm used in encrypting the text. This allows us to choose the encryption algorithm without the need to add a new data type.
||Encrypts the given text using symmetric cryptography according to the chosen algorithm, the key and the initialization vector (IV).
||Decrypts the given encrypted string using the specified algorithm, the key and the initialization vector (IV).
||Specifies the encryption algorithm to be used.
||Encryption key must be base-64 encoded. If no key is provided, it is generated automatically upon creating the instance (required when decrypting).
||Encryption initialization vector must be base-64 encoded. If no initialization vector is provided, it is generated automatically upon creating the instance (required when decrypting).
Note: The Key and IV (Initialization Vector) properties must be encoded using the Base64 format.
The reason for this requirement is that, internally, the encryption algorithm uses an array of bytes, which cannot always be represented as a String (it can have non-printable characters)..
In the example below, the text contained in variable &text is encrypted using the TripleDES algorithm.
// Make sure to use a String coded as Base64
&CryptoEncrypt.Key ="alNZVUNUc2hxeDBrT3VEczU4TnNoYjFPa1pqN21oMVM=" //CryptoEncrypt is of CryptoSymmetricEncrypt type
&CryptoEncrypt.Algorithm = CryptoEncryptAlgorithm.TripleDES
&result = &CryptoEncrypt.Encrypt(&Text) //The text is encrypted and the result obtained.
&Text = &CryptoEncrypt.Decrypt(&EncryptedText) //CryptoEncrypt is of CryptoSymmetricEncrypt type
msg(format("Error %1 %2", &Cryptoencrypt.ErrCode.ToString(), &Cryptoencrypt.ErrDescription))
||Web(.NET,Java), Smart Devices (iOS, Android)
This data type is available as of GeneXus 15.
For Smart Devices enviroment, is available as of Genexus 15 Upgrade 10 for iOS and GeneXus 15 Upgrade 11 for Android.