ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Encryption/compression functions
  • Asymmetric encryption of an envelope
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Warning
From version 28, EncryptAsymmetricEnvelopped is kept for backward compatibility. This function has been replaced with EncryptAsymmetricEnveloped.
Performs an asymmetric encryption of an envelope.
Example
// Encrypting a character string
//---------------------------------------
bufToEncrypt is Buffer = "Message to encrypt"
bufEncryptedMessage is Buffer
sPublicKeyFile is string = fExeDir() + "\PublicKey.pem"
sPublicKeyPassword is string = "xxx"

bufEncryptedMessage = EncryptAsymmetricEnveloped(bufToEncrypt, sPublicKeyFile, sPublicKeyPassword)

// Decryption  
// -------------
bufEncryptedMessage is Buffer
bufDecryptedMessage is Buffer
sPrivateKeyFile is string = fExeDir() + "\PrivateKey.pem"
sPrivateKeyPassword is string = "xxx"

bufDecryptedMessage = DecryptAsymmetricEnveloped(bufEncryptedMessage, sPrivateKeyFile, sPrivateKeyPassword)
bufToEncrypt is Buffer = "Message to encrypt"
bufEncryptedMessage is Buffer
bufPublicKey is Buffer
bufPrivateKey is Buffer
(bufPrivateKey, bufPublicKey) = EncryptGenerateRSAKey(1024)
// Encrypting a character string
//---------------------------------------
bufEncryptedMessage = EncryptAsymmetricEnveloped(bufToEncrypt, bufPublicKey)

// Decryption  
// -------------
bufEncryptedMessage is Buffer
bufDecryptedMessage is Buffer

bufDecryptedMessage = DecryptAsymmetricEnveloped(bufEncryptedMessage, bufPrivateKey)
Syntax
<Result> = EncryptAsymmetricEnveloped(<Content to encrypt> , <Public key file> [, <Password>])
<Result>: Buffer
All the information necessary for decryption (algorithms used, encrypted key, initialization vector and encrypted buffer).
<Content to encrypt>: Buffer
Buffer to encrypt.
<Public key file>: Character string or Buffer
  • Name and path of the file corresponding to the public key that will be used to encrypt. pem, der and p12 key formats are supported.
  • Buffer containing the public key that will be used for the encryption.
<Password>: Optional character string or secret string
Key file password (if required).
New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter must be "Ansi or Unicode string".
To learn more about secret strings and how to use the vault, see Secret string vault.
Remarks

Asymmetric encryption of an envelope

EncryptAsymmetricEnveloped generates a random encryption key that will be used to encrypt <Content to encrypt> with a symmetric algorithm.
The key is encrypted with the public key of <Public key file>.
<Result> contains a buffer that concatenates all the necessary information for the decryption (algorithms used, encrypted key, initialization buffer and encrypted buffer).
Remarks:
  • The private key is encrypted using OAEP padding.
  • The message is encrypted using AES 256 in CBC with PKCS padding.
Component: wd300com.dll
Minimum version required
  • Version 24
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 11/23/2024

Send a report | Local help