It enables us to encrypt a text using an asymmetrical algorithm.
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. |
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
endif
endif
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)
else
//Process Errors
endif
else
//Process Errors
endif
- iOS only support SHA256 (default) in Algorithm property. Other algorithms are ignored.
- Android uses RSA/ECB/OAEPWithSHA-256AndMGF1Padding in Algorithm property when the developer indicates an unsupported algorithm.
Platform |
Web(.NET,Java), Smart Devices (Android e iOS) |
This data type is available as of GeneXus 15.
For iOS is available as of Genexus 15 Upgrade 10.
For Android is available as of GeneXus 15 Upgrade 11.