ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / External file functions
  • Error handling
  • Operating mode in Windows Vista (and later)
  • Encrypting/Decrypting a character string
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Warning
From version 24, fCrypt is kept for backward compatibility. This function has been replaced with fEncrypt.
Encrypts a file in binary or ASCII format.
Note This file can be decrypted with fDecrypt.
Reports and Queries
// Cryptage d'un fichier
ResCrypte = fEncrypt("C:\MesRépertoires\Fichier.txt", "C:\MesRépertoires\FichierCrypté.txt", "MotDePasse")
Syntax
<Result> = fEncrypt(<Path of file to encrypt> , <Path of encrypted file> , <Password> [, <Type of encryption> [, <Format of encrypted file>]])
<Result>: Boolean
  • True if encryption has been performed,
  • False otherwise. To get more details on the error, use ErrorInfo with the errMessage constant.
<Path of file to encrypt>: Character string
Name and full (or relative) path of the file to encrypt (up to 260 characters). A UNC path can be used.
Windows This parameter can be in Ansi or Unicode format.
<Path of encrypted file>: Character string
Name and full (or relative) path of the encrypted file (up to 260 characters). A UNC path can be used.
Windows This parameter can be in Ansi or Unicode format.
<Password>: Character string or Secret string
Password used to encrypt the file. This password will be used to decrypt the encrypted file (fDecrypt). A long password provides better encryption security.
New in version 2025
Secret strings: If you use the secret string vault, the type of secret string used for this parameter must be "ANSI or Unicode string".
To learn more about secret strings and how to use the vault, see Secret string vault.
<Type of encryption>: Optional constant
Indicates the type of encryption:
encryptFast
(Default value)
Priority is given to the encryption speed (algorithm on 128 bits).
encryptNoneNo encryption is performed.
encryptRC516Priority is given to the encryption security (RC5 algorithm on 16 rounds).
encryptSecurePriority is given to the encryption security (RC5 algorithm on 128 bits).
<Format of encrypted file>: Optional Integer constant
Indicates the format of the encrypted 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.
encodeNone or FalseBinary format.
The encrypted file may contain non-printable characters. The file will be larger (about 4 bytes) than the initial 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.
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.

Remarks

Error handling

fEncrypt throws 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.
Reports and Queries

Operating mode in Windows Vista (and later)

If this function does not work 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).
In Windows Vista (and later), with the UAC mechanism (User Account Control) enabled, you must have administrator privileges to handle and/or modify the files or directories in system directories (Windows directory or "Program Files" directory).
Programming tip: If you need to manipulate / modify files or directories, without needing administrator privileges, it is advisable:
  • avoid writing to the Windows directory or to the "Program Files" directory,
  • use the system directory of the application (returned by SysDir with the srAppDataCommun constant, for example).
Remark: Under Windows Vista (and higher), the virtualization mechanism makes applications Vista-compatible.. 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.
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: wd300std.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 05/16/2025

Send a report | Local help