CryptoAsymmetricEncrypt data type

Official Content

It enables us to encrypt a text using an asymmetrical algorithm.

CryptoAsymmetricEncrypt Methods

Name Description
Encrypt(text:String)  For a given text, it returns it encrypted using asymmetrical cryptography according to the algorithm and the public key of the certificate specified.
Decrypt(text :String) Returns the given text de-encrypted according to the algorithm and the private key of the certificate specified. A requirement is that the certificate must contain the private key.


Algorithm:String Enables the specification of the hash algorithms that will be used. SHA256 is used by default
Certificate:CryptoCertificate   Allows us to specify the certificate that will be used for encrypting or de-encrypting.


A. Encrypt a text using an asymmetrical encryption algorithm.

The example below shows the encrypting of a text using a public key certificate.

&ErrorCode = &cryptoCert.Load("MyPublicKey.cer")
if &ErrorCode = 0
      &CryptoEncrypt.Certificate = &cryptoCert //&CryptoEncrypt is of CryptoAsymmetricEncrypt type
      &result = &CryptoEncrypt.Encrypt(&Text)
      if &CryptoEncrypt.ErrCode <> 0
           //Process Errors

B. De-encrypting an encrypted text with an asymmetrical algorithm.

This example shows how to de-encrypt an encrypted text using an asymmetrical algorithm.

&ErrorCode = &cryptoCert.Load("MyPFX.pfx",&pwd) //&CryptoCert is of CryptoCertificate type.
 if &ErrorCode= 0
    if &cryptoCert.HasPrivateKey() 
        &CryptoEncrypt.Certificate = &cryptoCert //&CryptoEncrypt is of the CryptoAsymmetricEncrypt type
        &Text= &CryptoEncrypt.Decrypt(&EncryptedText)
       //Process Errors
  //Process Errors


  • Smart Devices only support SHA256 (default) in Algorithm property. Other mechanisms are ignored.


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


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.