PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Decrypts a message that was encrypted with a standard encryption algorithm.
Unlike Crypt and Uncrypt, CryptStandard and UncryptStandard use the standard encryption algorithms that allow you to exchange encrypted messages between different runtime platforms (Windows, Linux, Android, Java, iOS, PHP, etc.) and/or with external tools.
PHP This function is available for the PHP sites from version 200051.
// Encrypt a character string by using the AES algorithm
sMessage is Buffer = "Message to encrypt"
bufKey is Buffer = HashString(HA_MD5_128, "password")
bufEncrypt is Buffer = CryptStandard(sMessage, bufKey, cryptAES128)
// Decryption
sResult is Buffer = UncryptStandard(bufEncrypt, bufKey, cryptAES128)
Info(sResult)
Syntax
<Result> = UncryptStandard(<Encrypted Message> , <Key> [, <Algorithm> [, <Operation Mode> [, <Fill>]]])
<Result>: Binary buffer
  • Result of decryption for the specified message,
  • Empty string ("") if an error occurred. To find out the error details, use ErrorInfo.
<Encrypted Message>: Binary buffer
Message to decrypt. This message can be the encryption result obtained during the call to CryptStandard.
This buffer must include two sections:
  • The initialization vector (or IV) used to encrypt data.
  • The encrypted data.
If the message was encrypted:
  • by CryptStandard, this parameter must correspond to the value returned by the function.
  • by an external tool, the buffer must be built by concatenating the encrypted data to initialization vector used.
Note: if the specified operation mode is cryptECB, no initialization vector was used to encrypt the message and in this case, the parameter must directly correspond to the encrypted data.
<Key>: Buffer
Key with which the data was encrypted. This key must be identical to the one supplied when encrypting the message.
<Algorithm>: Optional Integer constant
Encryption algorithm used. This parameter must correspond to the algorithm used to encrypt the message.
cryptAES128
(Default value)
Advanced Encryption Standard.
  • Size of key: 128 bits.
  • Size of blocks: 128 bits.
  • Size of initialization vector (IV): 128 bits.
Versions 23 and later
cryptAES256
New in version 23
cryptAES256
cryptAES256
Advanced Encryption Standard.
  • Size of key: 256 bits.
  • Size of blocks: 128 bits.
  • Size of initialization vector (IV): 128 bits.
AndroidAndroid Widget JavaPHP This constant is not available.
cryptDESData Encryption Standard.
  • Size of key: 64 bits.
  • Size of blocks: 64 bits.
  • Size of initialization vector (IV): 64 bits.
crypt3DESTriple Data Encryption Standard.
  • Size of key: 192 bits.
  • Size of blocks: 64 bits.
  • Size of initialization vector (IV): 64 bits.
<Operation Mode>: Optional Integer constant
Process mode of blocks by the encryption algorithm used. This parameter must correspond to the operation mode used to encrypt the message.
cryptCBC
(Default value)
Cipher Block Chaining - Sequence of blocks.
Versions 23 and later
cryptCFB
New in version 23
cryptCFB
cryptCFB
Cipher Feedback - Feedback encryption. This process mode is available if the algorithm used corresponds to the cryptAES256 constant.
AndroidAndroid Widget JavaPHP This constant is not available.
Versions 23 and later
cryptCTR
New in version 23
cryptCTR
cryptCTR
Cipher Counter - Encryption based on a counter. This process mode is available if the algorithm used corresponds to the cryptAES256 constant.
AndroidAndroid Widget JavaPHP This constant is not available.
cryptECBElectronic Code Book - Dictionary of codes. This operation mode is not recommended and it should only be used for compatibility reasons.
<Fill>: Optional Integer constant
Mode for filling the encrypted data in order to be compatible with the size required by the encryption algorithms by blocks. This parameter must correspond to the fill mode used to encrypt the message.
cryptPaddingPKCS
(Default value)
The data is filled with bytes whose value corresponds to the total number of bytes added to reach the requested size.
cryptPaddingZeroThe data is filled with binary zeros until the requested size is reached.
Related Examples:
The Crypt functions Unit examples (WINDEV): The Crypt functions
[ + ] Using the encryption/decryption functions of WINDEV.
This example is used to:
- Encrypt a character string
- Decrypt a character string
Components
WINDEVWEBDEV - Server codeReports and Queries wd230com.dll
Java wd230java.jar
Linux wd230com.so
Android wd230android.jar
Minimum required version
  • Version 20
This page is also available for…
Comments
Valida Criptografia e Descriptografia
//Chave valida sem caracteres especiais ASCII invisiveis e sem espaços em branco ou quebras de linha


loop
resultado = criaChave(valor) //cria a chave usando cryptstandar
if valida(resultado) = true //valida regras
break // se ok para de criar
end
end
BOLLER
May 09 2018
How to actually work between WM/WD/WB
https://forum.pcsoft.fr/en-US/pcsoft.us.windevmobile/2019-wm20-w20-uncryptstandard-cryptstandard/read.awp?hl=*
Jose
Apr. 25 2018
Example
//Exemplo para Criptografar
sMessage is Buffer = "Message to encrypt"
bufKey is Buffer = HashString(HA_CKSUM_64, "password")
bufEncrypt is Buffer = CryptStandard(sMessage, bufKey, cryptDES)

Info(bufEncrypt)

// Exemplo para Decriptografar
bufKey is Buffer = HashString(HA_CKSUM_64, "password")
sResult is Buffer = UncryptStandard(bufEncrypt, bufKey, cryptDES)

Info(sResult)



//E no Windev Mobile
//Criptografia
B_senha is Buffer = HashString(HA_HMAC_MD5_128, "bob-esponja")
B_resultado_Criptografado is Buffer = CryptStandard(buf_conteudo_sig, B_senha, cryptAES128)

info(B_resultado_Criptografado)


//Descriptografia
B_senha is Buffer = HashString(HA_HMAC_MD5_128, "bob-esponja")
B_resultado_Descriptografado is Buffer = UnCryptStandard(buf_conteudo_sig, B_senha, cryptAES128)

info(B_resultado_Descriptografado )
BOLLER
Mar. 16 2018