PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US

  • Managing errors
  • Operating mode in Windows Vista (and later)
  • Encrypting/Decrypting a character string
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
Encrypts a file in binary or ASCII format.
Note: This file can be decrypted by fUncrypt.
Versions 15 and later
Android This function is now available for the Android applications.
New in version 15
Android This function is now available for the Android applications.
Android This function is now available for the Android applications.
Versions 16 and later
PHP This function is now available for the PHP sites.
WINDEVLinux 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.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
PHP This function is now available for the PHP sites.
WINDEVLinux This function is now available for the WINDEV applications in Linux.
Versions 17 and later
iPhone/iPad This function is now available for the iPhone/iPad applications.
New in version 17
iPhone/iPad This function is now available for the iPhone/iPad applications.
iPhone/iPad This function is now available for the iPhone/iPad applications.
Versions 18 and later
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Android Widget This function is now available in Android Widget mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
WINDEVWEBDEV - Server codeReports and QueriesJavaAjaxUser code (UMC)
// Encrypt a file
ResEncrypt = fCrypt("C:\MyDirectories\File.txt", ...
"C:\MyDirectories\EncryptedFile.txt", "Password")
Windows Mobile
// Encrypt a file
ResEncrypt = fCrypt("\MyDirectories\File.txt", ...
"\MyDirectories\EncryptedFile.txt", "Password")
Syntax
<Result> = fCrypt(<Path of File to Encrypt> , <Path of Encrypted File> , <Password> [, <Type of Encryption> [, <Format of Encrypted File>]])
<Result>: Boolean
  • True if the encryption was performed,
  • False otherwise. To find out the error details, use ErrorInfo associated with the errMessage constant.
<Path of File to Encrypt>: Character string (with quotes)
Name and full (or relative) path of the file to encrypt (up to 260 characters). A UNC path can be used.
Versions 15 and later
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
Windows Mobile Name and full path of the file to encrypt (up to 260 characters).
Versions 17 and later
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories.
New in version 17
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories.
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories.
<Path of Encrypted File>: Character string (with quotes)
Name and full (or relative) path of the encrypted 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.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
New in version 15
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
WindowsLinux This parameter can be in Ansi or Unicode format.
AndroidAndroid Widget This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: In Android, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories, as well as onto the external memory (SDCard).
Windows Mobile This path must be a full path or a UNC path. It cannot be a relative path.
Versions 17 and later
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories.
New in version 17
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories.
iPhone/iPad This parameter can correspond to a full path or to a relative path in relation to the current directory (returned by fCurrentDir). This parameter is case sensitive.
Reminder: On iPhone/iPad, the file system is read-only on the device and on the emulator. An application has the rights to write into its setup directory or into one of its sub-directories.
<Password>: Character string (with quotes)
Password used to encrypt the file. This password will be used to decrypt the encrypted file (fUncrypt). A long password provides better encryption security.
<Type of Encryption>: Optional constant
Indicates the type of encryption:
cryptNoneNo encryption is performed.
cryptFast
(Default value)
Priority is given to the encryption speed (algorithm on 128 bits).
Java The algorithm used will be a Blowfish algorithm.
Versions 15 and later
AndroidAndroid Widget This constant is not available.
New in version 15
AndroidAndroid Widget This constant is not available.
AndroidAndroid Widget This constant is not available.
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).
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).
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
Indicates the format of the encrypted file:
encodePCS or True
(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.
encodeNone or FalseBinary format.
The encrypted file may contain non-printable characters. The file will be larger (about 4 bytes) than the initial file.
encodeBASE64BASE 64 format.
The file is encrypted with the BASE64 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.
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.
Remarks

Managing errors

fCrypt generates an error in the following cases:
  • the file to encrypt does not exist,
  • the file to encrypt is locked,
  • the path of the file to encrypt is invalid,
  • <Password> is an empty string,
  • the user has no read rights on the file to encrypt,
  • the user has no write rights on the encrypted file.
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)

Operating mode in Windows Vista (and later)

If this function does not operate properly in Windows Vista (and later), check whether the file used is not found 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 found in the system directories (Windows directory or "Program Files" directory).
Programming tip: To handle and/or modify the files without having 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).
Note: 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 Crypt and Uncrypt.
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 file in Java or Android and decrypt it with WINDEV (and conversely).
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
The Crypt functions Unit examples (WINDEV Mobile): The Crypt functions
[ + ] Using the WLanguage encryption and decryption functions.
This example is used to:
- Encrypt a character string
- Decrypt a character string
Components
WINDEVWEBDEV - Server codeReports and Queries wd230std.dll
Windows Mobile wp230std.dll
Java wd230java.jar
Linux wd230std.so
Android wd230android.jar
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment