PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Encryption/Decryption
DecryptStandard (Example)
Encryption/Decryption
Encryption/Decryption example.
bufEncryptionKey is Buffer
// with cryptAES128, the key is on 128 bits
// - Either we take the hash on 128 bits of any 'standard' key
// (to be done for the encryption and for the decryption)
bufEncryptionKey = HashString(HA_MD5_128, "encryption key")
// - Or we give a key with exactly the proper size 128 bits that is 16 bytes
// bufEncryptionKey="encryptkey128bits"
// For the encryption, a code example can be:  
// bufNotCrypted is buffer = "secret data"
// bufEncryptedData = CryptStandard(bufNotEncrypted, bufEnryptionKey, ...
//                 cryptAES128, cryptCBC, cryptPaddingPKCS)
 
// Decryption
WHEN EXCEPTION IN
bufResult is Buffer = DecryptStandard(bufEncryptedData, bufEncryptionKey, ...
cryptAES128, cryptCBC, cryptPaddingPKCS)
DO
// The decryption failed because the values are not correct:
// incorrect key size, insufficient message size for the initial vector...
ErrorThrow(1, ExceptionInfo())
END
 
IF ErrorOccurred THEN
// Decryption problem
Error("The decryption failed ", ErrorInfo())
ELSE
// Decryption OK, bufResult contains the decrypted buffer
Info("Decrypted data: ", bufResult)
END
Minimum version required
  • Version 20
This page is also available for…
Comments
Click [Add] to post a comment