|
|
|
|
|
DecryptAsymmetric (Function) In french: DécrypteAsymétrique Decrypts a buffer with a private/public key algorithm with RSA encryption. The data has been previously encrypted with EncryptAsymmetric.
bufToEncrypt is Buffer = "Message to encrypt"
bufEncryptedMessage is Buffer
sPublicKeyFile is string = fExeDir() + "\PublicKey.pem"
sPublicKeyPassword is string = "xxx"
bufEncryptedMessage = EncryptAsymmetric(bufToEncrypt, sPublicKeyFile, ...
sPublicKeyPassword, encryptPaddingPKCS1)
bufEncryptedMessage is Buffer
bufDecryptedMessage is Buffer
sPrivateKeyFile is string = fExeDir() + "\PrivateKey.pem"
sPrivateKeyPassword is string = "xxx"
bufDecryptedMessage = DecryptAsymmetric(bufEncryptedMessage, sPrivateKeyFile, ...
sPrivateKeyPassword, encryptPaddingPKCS1)
bufToEncrypt is Buffer = StringToUTF8("?????? Test")
bufPrivateKey is Buffer
bufPublicKey is Buffer
(bufPrivateKey, bufPublicKey) = EncryptGenerateRSAKey(1024)
bufEncrypted is Buffer = EncryptAsymmetric(bufToEncrypt, bufPublicKey)
bufSign is Buffer = CertificateSignString(bufEncrypted, bufPrivateKey, "", ...
certSignatureOnly + certSHA256)
IF CertificateCheckString(bufEncrypted, bufSign, bufPublicKey, "", "", ...
certSignatureOnly + certSHA256) THEN
bufReadable is Buffer = DecryptAsymmetric(bufEncrypted, bufPrivateKey)
Trace("Authentic message")
Trace(UTF8ToString(bufReadable))
ELSE
Trace("Unauthenticated message")
END
Syntax
<Result> = DecryptAsymmetric(<Content to decrypt> , <Private key file> [, <Password> [, <Padding>]])
<Result>: Buffer Decrypted data. <Content to decrypt>: Buffer Buffer to decrypt. <Private key file>: Character string or Buffer - Name and path of the file corresponding to the RSA private key to be used to decrypt the data. pem and p12 key formats are supported.
- Buffer containing the RSA private key to be used to decrypt the data.
<Password>: Optional string or Secret string Key file password (if required).
New in version 2025Secret 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. <Padding>: Optional Integer constant Padding mode for encrypted data (used during encryption) to be compatible with the size required by block encryption algorithms: | | encryptPaddingOAEP | Padding according to the OAEP algorithm (Optimal Asymmetric Encryption Padding). | encryptPaddingPKCS1 (Default value) | Padding according to the PKCS 1 algorithm (Public Key Cryptographic Standards). |
Related Examples:
|
Unit examples (WINDEV): Asymmetric encryption
[ + ] Using the asymmetric encryption functions (EncryptAsymmetric, DecryptAsymmetric)
|
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|