CryptoSymmetricEncrypt data type

Official Content

It enables us to encrypt a 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.

CryptoSymmetricEncrypt Methods

Name Description
Encrypt(text:String) For a given text, it returns an encrypted text using symmetric cryptography according to the algorithm, the key and the initialization vector -IV (*) specified.
Decrypt(text:String) Returns the given text, de-encrypted according to the algorithm, the key and the initialization vector -IV (*) specified.

Properties

Algorithm:CryptoAlgorithmEncrypt   Allows us to specify the encryption algorithm.
Key:String Encryption key generated automatically upon creating the instance (required when decrypting).
IV:String Encryption initialization vector generated automatically upon creating the instance (required when decrypting).
KeySize:Numeric  
BlockSize:Numeric  

Example   

A. How to encrypt a text using a symmetrical algorithm.

In the example below, the text contained in variable &text is encrypted using the TripleDES algorithm.

&CryptoEncrypt.Key ="jSYUCTshqx0kOuDs58Nshb1OkZj7mh1S" //CryptoEncrypt is of CryptoSymmetricEncrypt type.
&CryptoEncrypt.Algorithm = CryptoEncryptAlgorithm.TripleDES
&result = &CryptoEncrypt.Encrypt(&Text) //The text is encrypted and the result obtained.

B. How to de-encrypt an encrypted text with a symmetrical algorithm.

&Text = &CryptoEncrypt.Decrypt(&EncryptedText) //CryptoEncrypt is of CryptoSymmetricEncrypt type
//Process Errors
msg(format("Error %1 %2", &Cryptoencrypt.ErrCode.ToString(), &Cryptoencrypt.ErrDescription))

Scope

Platform  Web(.NET,Java), Smart Devices (iOS)

Availability

This data type is available as of GeneXus 15.
For Smart Devices enviroment, is available as of GeneXus 15 Upgrade 10.

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.