This built-in predicate attempts to decrypt a file, the file to decrypt is the first argument. The second argument is the name of the file to which the decrypted data is written to. The last argument is the key to use for decrypting.
The blowfish encryption algorithm is used to encrypt the files, a key size of 128 bits is used to encrypt the data. This key is generated by using the supplied password as input to initialize the encryption key. Because a good password is required Trinc-Prolog checks the entered passwords. The password rules are:
| Password examples | |
| test2_ | this password is too short |
| test2test | there is no symbolic or special character in the password |
| test2_test | this is a correct password |
The blowfish encryption algorithm is free to use, there are no patents restraining its use and also no export restrictions, it was introduced by Bruce Schneier in 1994. For more information about the blowfish encryption algorithm visit the website of Counterpane; www.counterpane.com.
| To protect the contents of encrypted modules it is not possible to use the clause/2 predicate for these modules. |
The text editor can also encrypt and decrypt files, for more information see: text editor.
see also: app_dir/1 base64_decode_file/2 base64_encode_file/2 compress_file/2 copy_file/2 current_dir/1 decompress_file/1 decompress_file/2 delete_file/1 encrypt_file/3 exists_dir/1 exists_file/1 info_file/2 make_dir/1 md5_file/2 next_file/2 next_file/3 next_dir/2 remove_dir/1 rename_file/2 set_current_dir/1 split_fn/2 unlink_file/1 wipe_file/1
| Examples | |
| decrypt_file('c:\\temp\\doc.epr', 'd:\\doc2.txt', 'test2_test') | the file 'doc.epr' is decrypted with the key 'test2_test' to the file 'd:\doc2.txt' |
| Exceptions | |
| The argument is an empty variable | an instantiation_error exception is thrown |
| The argument Arg is not an atom enclosed by single or double quotes | a type_error(atom_singlequotes, Arg) exception is thrown |
| The File to decrypt cannot be opened for reading | an existence_error(file, File) exception is thrown |
| The destination File to copy to cannot be opened for writing | a permission_error(write, file, File) exception is thrown |
| The decryption Key is a weak key | an evaluation_error(weak_encryption_key, Key) exception is thrown |
| The Key used for decrypting is invalid | an evaluation_error(incorrect_encryption_key, Key) exception is thrown |