PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Binary format of an encrypted string
  • Encrypting and decrypting an external file
  • Encryption in PHP
  • Encryption in Android/Java and decryption by a WINDEV application (or conversely)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Warning
From version 24, Crypt is kept for backward compatibility. This function is replaced by Encrypt.
Encrypts a character string in binary format or in ASCII format.
Remarks:
  • This character string can be decrypted by Decrypt.
  • If the encryption and the decryption are performed on different platforms (encryption in Android and decryption in Windows for example), use EncryptStandard and DecryptStandard. For more details, refer to the "Remarks" paragraph.
// Encrypt a string
Res = Encrypt("My credit card number is 52327453829011", "Password")
// Encode a string in base 64
bufBase64 is Buffer = Encrypt(bufToEncode, "", compressNone + cryptNone, encodeBASE64)
Syntax
<Result> = Encrypt(<String to encrypt> , <Password> [, <Type of encryption> [, <Format of encrypted string>]])
<Result>: Character string
  • Encrypted character string,
  • Empty string ("") if an error occurred. To get more details on the error, use ErrorInfo.
<String to encrypt>: Character string
Text to encrypt.
<Password>: Character string
Password used to encrypt the character string. This password will be used to decrypt the encrypted string (Decrypt). A long password optimizes the encryption security.
<Type of encryption>: Optional constant (or combination of constants)
Indicates the type of encryption and/or compression:
  • Type of encryption:
    cryptAnsiThe encryption is identical to the one performed in a WINDEV or WEBDEV application. Useful for the applications that encrypt in WINDEV Mobile and that decrypt in WINDEV for example.
    To use this constant, <Format of encrypted string> must correspond to the encodePCS constant.
    Remark: If the cryptAnsi constant is not combined with another constant specifying the type of encryption, the <Password> parameter is ignored.
    This constant can only be used in WINDEV Mobile for Windows CE.
    WINDEVWEBDEV - Server codeAndroidAndroid Widget iPhone/iPadJavaPHP This constant has no effect.
    cryptFast
    (Default value)
    Priority is given to the encryption speed (algorithm on 128 bits).
    Java The algorithm used will be a Blowfish algorithm.
    AndroidAndroid Widget This constant is not available.
    PHP The algorithm used will be a Blowfish algorithm with 16 rounds.
    cryptNoneNo encryption is performed
    cryptRC516Priority is given to the encryption security (RC5 algorithm on 16 rounds).
    AndroidAndroid Widget JavaPHP This constant has no effect.
    cryptSecurePriority is given to the encryption security (RC5 algorithm on 128 bits).
    AndroidAndroid Widget Java The algorithm used will be a PBE algorithm (Password Based Encryption).
    PHP The algorithm used will be a 128-bit RINJDAEL algorithm.
  • Type of compression:
    compressLZWThe string will be compressed before it is encrypted.
    AndroidAndroid Widget JavaPHP This constant has no effect.
    compressNone
    (Default value)
    No compression is performed.
    AndroidAndroid Widget JavaPHP This constant has no effect.
    compressShortStringThe string will be compressed via an algorithm optimized for the short character strings. This compression will be efficient only if the cryptNone constant is selected and if <Format of encrypted string> corresponds to the encodeNone constant.
    AndroidAndroid Widget JavaPHP This constant has no effect.
<Format of encrypted string>: Optional Integer constant
Indicates the format of encrypted string:
encodeBASE64BASE 64 format. The file is encrypted with the BASE64 algorithm. The encrypted file will be larger (about 30%) than the initial file.
To perform an encoding in base 64, you also have the ability to use Encode associated with the encodeBASE64 or encodeBASE64URL constant.
The base64 format can be used to insert an encrypted file into the email body for example.
encodeNoneBinary format. The encrypted file may contain non-printable characters. The file will be larger (about 4 bytes) than the initial file.
encodePCS
(Default value)
ASCII format. The encrypted file will contain printable characters only. The encrypted file will be larger (about 30%) than the initial file.
This format can be used to insert an encrypted file into the email body for example.
encodeUUEncodeUUEncode format. The file is encrypted with the UUEncode algorithm. The encrypted file will be larger (about 30%) than the initial file.
This format can be used to insert an encrypted file into the email body for example.
AndroidAndroid Widget Java This parameter is ignored. The encrypted string will be in BASE 64 format.
Remarks
WINDEVWEBDEV - Server codeReports and QueriesUniversal Windows 10 AppUser code (UMC)PHPAjax

Binary format of an encrypted string

The encrypted string must be handled with great care when <Format of encrypted string> corresponds to the encodeNone constant. Indeed, this encrypted string may contain end of string characters. In this case, the string will be truncated by the display operations.
Part of the encrypted information will be lost if:
  1. The encrypted string is displayed in a control.
  2. The value of this control is used for the decryption.
However, no information will be lost if the encrypted string is handled as a string variable.

Encrypting and decrypting an external file

To encrypt/decrypt an external file, use fEncrypt and fDecrypt.
PHP

Encryption in PHP

In PHP, the BlowFish encryption (cryptFast constant) and the RINJDAEL encryption (cryptSecure constant) are based on the MCrypt library. This library is commonly used by the PHP hosting companies and therefore it is always enabled. This library can be downloaded from the PHP site.
To enable (if necessary) this library locally, the following elements are required:
  • PHP installed.
  • the PHP.INI file found in the Windows directory must include the "extension=php_mcrypt.dll" line.
  • the php_mcrypt.dll file must exist in the directory of PHP extensions. This directory is defined in the PHP.INI file by the "extension_dir" variable.
AndroidJava

Encryption in Android/Java and decryption by a WINDEV application (or conversely)

Caution: the encryption/decryption algorithms used in Java and Android differ from the ones used by WINDEV. Therefore, you cannot encrypt a character string in Java or Android and decrypt it with WINDEV (and conversely).
To encrypt a character string in Java or Android and to decrypt it with WINDEV (or conversely), use EncryptStandard and DecryptStandard.
Component: wd280std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Example Encripta
//https://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/2251-about-cryptstandart-and-uncryptstandart-2254/read.awp

Encripta(St is string, Pw is string)
x is string
i is int
n is int
p is int
j is int
//n0 is int
ok is boolean

p = 0

FOR i = 1 TO Length(St)
p += 1
IF p > Length(Pw) THEN p = 1
j = Asc(Middle(Pw, p, 1)) OR 128
n = Asc(Middle(St, i))

ok = False

WHILE ok = False
n = BinaryXOR(n, j) //encripta...
IF n < 31 THEN //se char de controle
n = (128 + n) //somar 128 e
//GoTo DeNovo //ecripta novamente
ELSE IF n > 127 AND n < 159 THEN //se nesta faixa pode ser char de controle
n = n - 128 //tira 128 e
//GoTo DeNovo //encripta novamente
ELSE
ok = True
END
END
x = x + Charact(n) //concatena string encriptada


END

RESULT x
BOLLER
05 Apr. 2017