[top] [up] [next]

Saving, compressing, encrypting a module


A module can also be saved, if a module is saved the compiled code is translated back to readable text and saved to a text file. This means that comments placed inside a module are not saved. Compile directives like public and dynamic are saved. There are three versions of the predicate save_module.

    save_module( <internal-name> ).
    save_module( <internal-name>, <file-name> ).
    save_module( <internal-name>, <file-name>, [save_options] ).

Examples:

    save_module( m23 ).
    save_module( m23, "c:\\prj\\logint\\test1.txt" ).
    save_module( m23, "c:\\prj\\logint\\test1.txt", [compress, encrypt(store_key, 'test2_test')] ).
Compression

The predicate save_module/3 has the save-option compress/0. When this option is used the module is saved in the compressed gzip format, files stored in this format have the .gz extension. It is possible to open the compressed files with other (de)compression utilities like WinZip or GZip.

Arrow.gif (1632 bytes) The text editor of Trinc-Prolog can automatically decompress a .gz file, it is also possible to compress a file by selecting it to save it as a .gz file.
Encryption

The blowfish encryption algorithm is used to encrypt the files, size of the key is 128 bits. The blowfish encryption algorithm is free to use, there are no patents restraining its use and no export restrictions. It was introduced by Bruce Schneier of Counterpane in 1994. For more information about the blowfish encryption algorithm visit the website of Counterpane; www.counterpane.com. The 128 bit 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 rules for password checking are:

Arrow.gif (1632 bytes) To protect the contents of encrypted modules it is not possible to use the clause/2 predicate for these modules.
Password management

The first parameter of the encrypt/2 save-option determines how the encryption password is managed by the person that will decrypt the file. The three available options are:  

Trinc-Prolog can detect if the entered password was correct, it does that by calculating an MD5 digest for the original data being encrypted and comparing it with the MD5 digest calculated while decrypting. Incorrect passwords are never stored. The MD5 digest algorithm is described in rfc1321.

[top] [up] [next]

 

info@trinc-prolog.com