The EncryptDecrypt class uses several Cryptography API Functions to implement password-protected encryption and decryption of files.
Do you think there are some similarities?
Here is an example of code that encrypts a file:
LOCAL oEnc As EncryptDecrypt
oEnc = CREATEOBJECT("EncryptDecrypt")
WITH oEnc
IF NOT .GenerateKey("foxpro") && a password
? .errorno, .errormessage
ELSE
IF NOT .EncryptFile("c:\myfiles\somefile.txt",;
"c:\myfiles\somefile.enc")
? .errorno, .errormessage
ENDIF
ENDIF
ENDWITH
The decryption is same simple:
WITH oEnc
IF NOT .GenerateKey("foxpro") && use same password
? .errorno, .errormessage
ELSE
IF NOT .DecryptFile("c:\myfiles\somefile.enc",;
"c:\myfiles\somefile.enc.txt")
? .errorno, .errormessage
ENDIF
ENDIF
ENDWITH
Default cryptographic service provider (CSP) is used along with algorithms CALG_MD5 for hashing and CALG_RC4 for encryption/decryption.
Before encrypting or decrypting files, user must provide a password using the GenerateKey method of the class. A cryptographic session key is created from the hash of this password.
A file is processed as a single block.
* * *
Oct.29, 2008: the EncryptBuffer method now allocates correct buffer size in cases when encrypted data is larger than the original plain text.
Credits: PHP (4.4.9), an HTML-embedded scripting language,
MySQL (5.1.55-log), the Open Source standard SQL database,
AceHTML Freeware
Version 4, freeware HTML Editor of choice. Hosted by Korax Online Inc.