PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Managing errors
  • Operating mode in Windows Vista (and later)
  • Encrypting/Decrypting a character string
  • 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, fUncrypt is kept for backward compatibility. This function is replaced by fDecrypt.
Decrypts a file that was encrypted by fEncrypt.
Versions 16 and later
PHP This function is now available for PHP sites.
Linux This function is now available for WINDEV applications in Linux.
New in version 16
PHP This function is now available for PHP sites.
Linux This function is now available for WINDEV applications in Linux.
PHP This function is now available for PHP sites.
Linux This function is now available for WINDEV applications in Linux.
WEBDEV - Server codeAjax
// Decrypt a file
ResDecrypt = fDecrypt("C:\MyDir\EncryptedFile.txt", ...
"C:\MyDir\DecryptedFile.txt", "Password")
Syntax
<Result> = fDecrypt(<Path of file to decrypt> , <Path of decrypted file> , <Password> [, <Type of encryption used> [, <Format of encrypted file>]])
<Result>: Boolean
  • True if the decryption was performed,
  • False otherwise. To find out the error details, use ErrorInfo associated with the errMessage constant.
<Path of file to decrypt>: Character string (with quotes)
Name and full (or relative) path of the file to decrypt (up to 260 characters). A UNC path can be used. This file must have been encrypted by fEncrypt.
Versions 15 and later
WindowsLinux This parameter can be in Ansi or Unicode format.
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
WindowsLinux This parameter can be in Ansi or Unicode format.
<Path of decrypted file>: Character string (with quotes)
Name and full (or relative) path of the decrypted file (up to 260 characters). A UNC path can be used.
Versions 15 and later
WindowsLinux This parameter can be in Ansi or Unicode format.
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
WindowsLinux This parameter can be in Ansi or Unicode format.
<Password>: Character string (with quotes)
Password used to decrypt the file. This password must be identical to the password used to encrypt the file. A long password provides better encryption security.
<Type of encryption used>: Optional constant
Specifies the type of encryption performed. This parameter must be identical to the one specified during the encryption.
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 is 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 RIJNDAEL algorithm.
New in version 16
PHP The algorithm used will be a 128-bit RIJNDAEL algorithm.
PHP The algorithm used will be a 128-bit RIJNDAEL algorithm.
<Format of encrypted file>: Optional Integer constant
Specifies the format of the encrypted file. This parameter must be identical to the one specified during the encryption.
encodePCS or TrueASCII format. The encrypted file will contain printable characters only.
encodeNone or False
(Default value)
Binary format. The encrypted file may contain non-printable characters.
encodeBASE64BASE 64 format. The encrypted file will contain printable characters only.
encodeUUEncodeUUEncode format. The encrypted file will contain printable characters only.
Remarks

Managing errors

fDecrypt generates an error in the following cases:
  • the file to decrypt does not exist or it is locked,
  • the path of the file to decrypt is invalid,
  • the <Password> is an empty string or it differs from the <Password> used to encrypt the file,
  • the <Type of decryption> differs from the <Type of encryption> specified during the encryption,
  • the <Format of encrypted file> differs from the one specified during the encryption,
  • the user has no read rights on the file to decrypt,
  • the user has no write rights on the file to decrypt.
  • a Unicode string was used for the <Path of file to decrypt> or for the <Path of decrypted file> in an operating system such as Windows 98 or Windows Me.
WEBDEV - Server code

Operating mode in Windows Vista (and later)

If this function does not operate properly in Windows Vista (and later), check whether the file or directory used is not in one of the system directories (Windows directory or "Program Files" directory).
Indeed, in Windows Vista (and later), with the UAC mechanism (User Account Control) enabled, you must have the administrator privileges to handle and/or modify the files or directories in the system directories (Windows directory or "Program Files" directory).
Programming tip: To handle and/or modify the files or directories without administrator privileges, you should:
  • avoid writing into the Windows directory or into the "Program Files" directory,
  • use the system directory corresponding to the application (returned by SysDir associated with the srCommonAppData constant).
Remark: In Windows Vista and later, the virtualization mechanism is used to make the applications "compatible with Vista". If the file is created in a system directory without having sufficient rights, this file will actually be created in another directory (C:\Users\<LOGIN>AppData\Local\VirtualStore\Windows\). In this case, the file cannot be shared between several applications.

Encrypting/Decrypting a character string

To encrypt/decrypt a character string, use Encrypt and Decrypt.
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 (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
Click [Add] to post a comment