PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Encrypting and decrypting an external file
  • Decrypting a stream in base64binary format
  • Encryption in PHP
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
Warning
From version 24, Uncrypt is kept for backward compatibility. This function is replaced by Decrypt.
Decrypts a character string that was encrypted by Encrypt.
Versions 20 and later
Note: If the encryption and the decryption are performed on different platforms (encryption in Android and decryption in Windows for example), use EncryptStandard and DecryptStandard. See "Remarks" for more details.
New in version 20
Note: If the encryption and the decryption are performed on different platforms (encryption in Android and decryption in Windows for example), use EncryptStandard and DecryptStandard. See "Remarks" for more details.
Note: If the encryption and the decryption are performed on different platforms (encryption in Android and decryption in Windows for example), use EncryptStandard and DecryptStandard. See "Remarks" for more details.
Versions 16 and later
PHP This function is now available for the PHP sites.
Linux This function is now available for the WINDEV applications in Linux.
New in version 16
PHP This function is now available for the PHP sites.
Linux This function is now available for the WINDEV applications in Linux.
PHP This function is now available for the PHP sites.
Linux This function is now available for the WINDEV applications in Linux.
// Encrypt a string
ResEncrypt = Encrypt("The number of my bank account in Switzerland is 74538290", "Password")
...
// Decrypt the string
Res = Decrypt(ResEncrypt, "Password")
 
// Decode the data encoded in base 64
bufDecode is Buffer = Decrypt(bufBase64, "", crypteNone, encodeBASE64)
 
Syntax
<Result> = Decrypt(<Encrypted string> , <Password> [, <Type of encryption used> [, <Format of encrypted string>]])
<Result>: Character string
  • Decrypted character string,
  • Empty string ("") if an error occurred. To find out the error details, use ErrorInfo.
<Encrypted string>: Character string (with quotes)
Encrypted character string. This character string was encrypted by Encrypt.
<Password>: Character string (with quotes)
Password used to decrypt the character string. This password must be identical to the password that was used to encrypt the character string. A long password provides better encryption security.
<Type of encryption used>: Optional constant (or combination of constants)
Specifies the type of encryption and compression performed. This parameter must be identical to the one specified during the encryption.
  • Type of encryption:
    cryptAnsi
    WEBDEV - Server codeWindowsLinuxPHP This constant has no effect.
    cryptNoneNo encryption was performed.
    cryptFast
    (Default value)
    Priority was given to the encryption speed (algorithm on 128 bits).
    Versions 16 and later
    PHP The algorithm used will be a Blowfish algorithm with 16 rounds.
    New in version 16
    PHP The algorithm used will be a Blowfish algorithm with 16 rounds.
    PHP The algorithm used will be a Blowfish algorithm with 16 rounds.
    cryptRC516Priority was given to the encryption security (RC5 algorithm on 16 rounds).
    PHP This constant has no effect.
    cryptSecurePriority was given to the encryption security (RC5 algorithm on 128 bits).
    Versions 16 and later
    PHP The algorithm used will be a 128-bit RINJDAEL algorithm.
    New in version 16
    PHP The algorithm used will be a 128-bit RINJDAEL algorithm.
    PHP The algorithm used will be a 128-bit RINJDAEL algorithm.
  • Type of Compression:
    compressNone
    (Default value)
    No compression is performed.
    PHP This constant has no effect.
    compressShortStringThe string is 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.
    PHP This constant has no effect.
    compressLZWThe string is compressed before it is encrypted.
    PHP This constant has no effect.
<Format of encrypted string>: Optional Integer constant
Indicates the format of the encrypted string. This parameter must be identical to the one specified during the encryption.
encodePCS or True
(Default value)
ASCII format. The encrypted file contains printable characters only.
encodeNone or FalseBinary format. The encrypted file may contain non-printable characters.
encodeBASE64BASE 64 format. The encrypted file contains printable characters only.
To decode a buffer in base 64, you also have the ability to use Decode associated with the encodeBASE64 constant.
encodeUUEncodeUUEncode format. The encrypted file contains printable characters only.
Remarks

Encrypting and decrypting an external file

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

Decrypting a stream in base64binary format

To decrypt a string encrypted in base64, you must use:
ResultString = Decrypt(EncryptedString, "", cryptNone, encodeBASE64)
// or
ResultString = Decrypt(EncryptedString, encodeBASE64)
 
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.
Related Examples:
The encryption functions Unit examples (WEBDEV): The encryption functions
[ + ] This example explains how to use the encryption/decryption functions of WEBDEV. This example allows you to:
- Encrypt a character string
- Decrypt a character string
The encryption functions Unit examples (WINDEV): The encryption functions
[ + ] Using the encryption/decryption functions of WINDEV.
This example is used to:
- Encrypt a character string
- Decrypt a character string
The encryption functions Unit examples (WINDEV Mobile): The encryption functions
[ + ] Using the WLanguage encryption and decryption functions.
This example is used to:
- Encrypt a character string
- Decrypt a character string
Component : wd240std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Exemplo Transformar Base String 64 Em Pdf
s_xml_documento is string="D:\amarildo\Giuliano_Sapucaia\xmlserv_15417338000110\xmlserv_Retorno\12-nfsepdf.xml"
s_meu_xml is string=fLoadText(s_xml_documento)
XMLDocument("XML1",s_meu_xml)
s_string_em_formato_base64 is string=XMLRead("XML1","/resPedidoLoteNFSePDF/NFS-ePDF")
s_transforma_pdf is string = Uncrypt(s_string_em_formato_base64 ,"",cryptNone,encodeBASE64)
//No Mobile // s_transforma_pdf = Uncrypt(s_string_em_formato_base64 ,"",cryptNone)
// //no Mobile o ultimo parâmetro e ignorado
fSaveBuffer("E:\aleva\teste3.pdf",s_transforma_pdf)
ShellExecute("E:\aleva\teste3.pdf")

//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/03/curso-windev-string-004-transformar.html
De matos AMARILDO
03 Mar. 2016