AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de cifrado/compresión
Descifra un buffer con un algoritmo de clave privada/pública según el cifrado RSA. Los datos se cifraron previamente con la función .EncryptAsymmetric.
Ejemplo
// Encrypting a character string
// ---------------------------------------
bufToEncrypt is Buffer = "Message to encrypt"
bufEncryptedMessage is Buffer
sPublicKeyFile is string = fExeDir() + "\PublicKey.pem"
sPublicKeyPassword is string = "xxx"
 
bufEncryptedMessage = bufToEncrypt.EncryptAsymmetric(sPublicKeyFile, ...
sPublicKeyPassword, cryptPaddingPKCS1)
 
// Decryption  
// -------------
bufEncryptedMessage is Buffer
bufDecryptedMessage is Buffer
sPrivateKeyFile is string = fExeDir() + "\PrivateKey.pem"
sPrivateKeyPassword is string = "xxx"
 
bufDecryptedMessage = bufEncryptedMessage.DecryptAsymmetric(sPrivateKeyFile, ...
sPrivateKeyPassword, cryptPaddingPKCS1)
bufToEncrypt is Buffer = StringToUTF8("สวัสดี Test")
bufPrivateKey is Buffer
bufPublicKey is Buffer
(bufPrivateKey, bufPublicKey) = EncryptGenerateRSAKey(1024)
// Encryption
bufEncrypted is Buffer = bufToEncrypt.EncryptAsymmetric(bufPublicKey)
bufSign is Buffer = CertificateSignString(bufEncrypted, bufPrivateKey, "", ...
certSignatureOnly + certSHA256)
// Decryption
IF CertificateCheckString(bufEncrypted, bufSign, bufPublicKey, "", "", ...
certSignatureOnly + certSHA256) THEN
bufReadable is Buffer = bufEncrypted.DecryptAsymmetric(bufPrivateKey)
Trace("Authentic message")
Trace(bufReadable.UTF8ToString())
ELSE
Trace("Unauthenticated message")
END
Sintaxis
<Result> = <Content to decrypt>.DecryptAsymmetric(<Private key file> [, <Password> [, <Padding>]])
<Result>: Buffer
Datos descifrados.
<Content to decrypt>: Buffer
Buffer a descifrar.
<Private key file>: Cadena de caracteres o memoria intermedia
  • Nombre y ruta del archivo que corresponde a la clave privada RSA que se utilizará para descifrar los datos. Los formatos de clave pem, y p12 están soportados.
  • Buffer que contiene la clave privada RSA que se utilizará para descifrar los datos.
<Password>: Cadena de caracteres opcional
Contraseña del archivo de claves (si es necesario).
<Padding>: Constante opcional de tipo Integer
Modo de relleno (utilizado durante el cifrado) para que los datos cifrados sean compatibles con el tamaño requerido por los algoritmos de cifrado por bloques:
cryptPaddingOAEPRelleno según el algoritmo OAEP (Optimal Asymmetric Encryption Padding).
cryptPaddingPKCS1
(Valor predeterminado)
Relleno según el algoritmo PKCS 1 (Public Key Cryptographic Standards).
Componente: wd290com.dll
Versión mínima requerida
  • Versión 26
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 22/06/2023

Señalar un error o enviar una sugerencia | Ayuda local