Wednesday, August 31, 2005

Work on the vfpencryption.fll continues at a steady pace (whenever a minute or two presents itself). I've finished fixing a couple more bugs that were reported to me and I've finished the EncryptFile() and DecryptFile() functions. Here is the download link and some additional information regarding the FLL that will be of use to developers who are using it.

Download the Latest Version of the VFP Encryption FLL (58 KB approx.)


Function ENCRYPT()

Signature: Encrypt(cStringtoEncrypt, cSecretKey[, nEncryptionType[, nEncryptionMode]])

Parameters:

cStringtoEncrypt - A plain text string that you want to have encrypted, such as "Hello World!"

cSecretKey - A plain text string that is the Key you want used during encryption, such as "My_SeCrEt_KeY".
Please note that keys may need to be of a particular length for certain types of encryption. Refer below for more information.

nEncryptionType - There are currently 5 types of encryption available. The value of this parameter determines that type of encryption used and how long your Secret Key should be. A single character in Visual FoxPro is  equal to 1 byte or 8 bits. So an encryption algorithm requiring a 128-bit key would need a Secret Key of 16 characters (16 x 8 = 128).

   0 = AES128 (requires a 16 character Key)
   1 = AES192 (requires a 24 character Key)
   2 = AES256 (requires a 32 character Key) *Default
   4 = Blowfish (requires a 56 character Key)
   8 = TEA (requires a 16 character Key)

nEncryptionMode - There are three different modes available for the each of the encryption types listed above. They include: Electronic Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB).

   0 = ECB *Default
   1 = CBC
   2 = CFB

Return Value:

Character data type - the encrypted form of cStringtoEncrypt.

Remarks:

When saving the return value of Encrypt() function to a field in a table, remember that Visual FoxPro will append blanks to the end of the string in order to fill the character field to its designated length. This can cause problems when decrypting the data as the spaces will be considered part of the encrypted string. To work around this, I suggest placing a single CHR(0) at the end of the encrypted string when saving it to the table. Then when decrypting the data just the portion prior to the CHR(0) can be sent into the Decrypt() function.


Function DECRYPT()

Signature: Decrypt(cEncryptString, cSecretKey[, nDecryptionType[, nDecryptionMode]])

Parameters:

cEncryptedString - A string that has been encrypted using the Encrypt() function.

cSecretKey - A plain text string that is the same Key that you used when you encrypted the data using the Encrypt function, such as "My_SeCrEt_KeY".
Please note that keys may need to be of a particular length for certain types of decryption. Refer below for more information.

nDecryptionType - There are currently 5 types of decryption available and they correspond to the same ones available in Encrypt(). A single character in Visual FoxPro is  equal to 1 byte or 8 bits. So an decryption algorithm requiring a 128-bit key would need a Secret Key of 16 characters (16 x 8 = 128).

   0 = AES128 (requires a 16 character Key)
   1 = AES192 (requires a 24 character Key)
   2 = AES256 (requires a 32 character Key) *Default
   4 = Blowfish (requires a 56 character Key)
   8 = TEA (requires a 16 character Key)

nDecryptionMode - There are three different modes available for the each of the encryption types listed above. They include: Electronic Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB).

   0 = ECB *Default
   1 = CBC
   2 = CFB

Return Value:

Character data type - the decrypted form of cEncryptedString followed by a variable number of CHR(0)s. See Remarks below for further clarification

Remarks:

IMPORTANT: Decryption is done on blocks of memory, so when the decrypt function returns the encrypted string it will be followed by a variable number of CHR(0)s unless the decrypted string just happens to end at exactly the same location as the last block decrypted. These extraneous CHR(0)'s can be removed using a number of Visual FoxPro functions, such as STRTRAN(), CHRTRAN(), or a combination of LEFT() and AT().



Function ENCRYPTFILE()

Signature: EncryptFile(cFiletoEncrypt, cDestinationFile, cSecretKey[, nEncryptionType[, nEncryptionMode]])

Parameters:

cFiletoEncrypt - A plain text string that is the fullpath to the file you wish to be encrypted, such as "C:\SensitiveInfo.doc"

cDestinationFile - A plain text string that is the fullpath to an encrypted file you wish to have created on disk, such as "C:\EncryptedInfo.doc". If this file doesn't exist then it will be created for you.

cSecretKey - A plain text string that is the Key you want used during encryption, such as "My_SeCrEt_KeY".
Please note that keys may need to be of a particular length for certain types of encryption. Refer below for more information.

nEncryptionType - There are currently 5 types of encryption available. The value of this parameter determines that type of encryption used and how long your Secret Key should be. A single character in Visual FoxPro is  equal to 1 byte or 8 bits. So an encryption algorithm requiring a 128-bit key would need a Secret Key of 16 characters (16 x 8 = 128).

   0 = AES128 (requires a 16 character Key)
   1 = AES192 (requires a 24 character Key)
   2 = AES256 (requires a 32 character Key) *Default
   4 = Blowfish (requires a 56 character Key)
   8 = TEA (requires a 16 character Key)

nEncryptionMode - There are three different modes available for the each of the encryption types listed above. They include: Electronic Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB).

   0 = ECB *Default
   1 = CBC
   2 = CFB

Return Value:

None

Remarks:

Currently the cFiletoEncrypt and cDestinationFile parameters cannot point to the same file. This may be revised in a future version. But for safety sake, this function requires that the original file be left untouched.



Function DECRYPTFILE()

Signature: DecryptFile(cEncryptedFile, cDestinationFile, cSecretKey[, nDecryptionType[, nDecryptionMode]])

Parameters:

cEncyptedFile - A plain text string that is the fullpath to the file you wish to be decrypted, such as "C:\EncryptedInfo.doc"

cDestinationFile - A plain text string that is the fullpath to a decrypted file you wish to have created on disk, such as "C:\SensitiveInfo.doc". If this file doesn't exist then it will be created for you.

cSecretKey - A plain text string that is the same Key that you used when you encrypted the data using the Encrypt function, such as "My_SeCrEt_KeY".
Please note that keys may need to be of a particular length for certain types of decryption. Refer below for more information.

nDecryptionType - There are currently 5 types of decryption available and they correspond to the same ones available in Encrypt(). A single character in Visual FoxPro is  equal to 1 byte or 8 bits. So an decryption algorithm requiring a 128-bit key would need a Secret Key of 16 characters (16 x 8 = 128).

   0 = AES128 (requires a 16 character Key)
   1 = AES192 (requires a 24 character Key)
   2 = AES256 (requires a 32 character Key) *Default
   4 = Blowfish (requires a 56 character Key)
   8 = TEA (requires a 16 character Key)

nDecryptionMode - There are three different modes available for the each of the encryption types listed above. They include: Electronic Code Book (ECB), Cipher Block Chaining (CBC) and Cipher Feedback Block (CFB).

   0 = ECB *Default
   1 = CBC
   2 = CFB

Return Value:

None

Remarks:

As with EncryptFile(), the cFiletoEncrypt and cDestinationFile parameters cannot point to the same file.


Function HASH()

Signature: Hash(cStringtoHash[, nHashType])

Parameters:

cStringtoHash - A plain text string you wish to have hashed

nHashType - The type of hash function to generate. There are currently 7 different hash functions supported

1 = SHA1 (a.k.a SHA160)
2 = SHA256
3 = SHA384
4 = SHA512 *Default
5 = MD5
6 = RIPEMD128
7 = RIPEMD256

Return Value:

Binary Character Data - the hash for cStringtoHash.

Remarks:

The hash is returned as a series of binary characters. However, it is more common to see hashes in a hexBinary format. This can be accomplished in Visual FoxPro by taking the return of the Hash() function and sending it in as a parameter to the STRCONV() function. For example:

?STRCONV(Hash("Some String"), 15) && hexBinary Hash

Thursday, September 01, 2005 2:22:53 AM (Central Daylight Time, UTC-05:00)  #    Comments [13]
Wednesday, December 21, 2005 5:21:07 PM (Central Standard Time, UTC-06:00)
Hi,

This is one of the best FLL's i've ever found in regards to its simplicity and power. Please, please continue work on this. Can I be of any support in the development of this library? I do not think I could live without it anymore :)

I've always wanted to have strong encryption in my apps but vfp does not natively support this. I know you can use Windows API's to do this but not with the speed and ease this FLL allows you to.

I have just discovered an issue I have not looked into yet. I've tried to use the encrypt and decypt functions on a windows 98 computer and it does not work? What does the fll rely on in regards to win32 etc? Does it support all (or most) windows OS's? The same code runs on my XP SP2 computer just not on my 98. Any help with this would be greatly apreciated.

As I said, if I can support this work in anyway whatsoever please let me know.

Thanks

Richard
Richard Norris
Saturday, January 21, 2006 3:15:26 PM (Central Standard Time, UTC-06:00)
al momento de ejecutar el programa de encriptacion que usa la ultima version del vfencryption.ffl sale un mensaje de error:
el archivo de biblioteca no es valido
Daniel Sanchez
Tuesday, January 24, 2006 11:44:45 PM (Central Standard Time, UTC-06:00)
en VFP 8 dice que la libreria no es valida
agradeceria me ayuden. ya que es interesante la tecnica de encriptacion
Luis Daniel Sanchez
Saturday, March 18, 2006 2:47:09 PM (Central Daylight Time, UTC-05:00)
I tried this with VFP 8 and 9 on WinXP SP2 and got the "Library file .... is invalid" error message. Works fine on Win2000. Any ideas?

Thanks.
Sam Thornton
Saturday, March 18, 2006 2:51:14 PM (Central Daylight Time, UTC-05:00)
Never mind. Works fine with vfpencryption71.fll.

Thanks.
Sam Thornton
Wednesday, March 29, 2006 3:32:51 PM (Central Daylight Time, UTC-05:00)
Tengo el mismo problema. Me marca en algunos equipos que la librería no es válida "Library file .... is invalid".

Espero me puedan indicar cómo arreglarlo, ya que en mi máquina funciona bien pero en otros equipos no.

Gracias.
Gerardo Pederzini
Wednesday, April 05, 2006 1:53:01 PM (Central Daylight Time, UTC-05:00)
This library is excellent. Unfortunately, I'm having trouble with the hashFile() function. I get intermittent but persistent "API call caused an exception" errors when attempting to hash any single file (tested with three different files). Are there any limitations (size, spaces-in-filename, etc.) that may be causing the error? -JC
John Clarke
Thursday, June 22, 2006 3:24:50 PM (Central Daylight Time, UTC-05:00)
I too get the "library file is invalid" with VFP 8 SP2. Is there a newer compilation?
Roger Jeffs
Thursday, August 24, 2006 9:33:21 PM (Central Daylight Time, UTC-05:00)
I've tried this awesome library in win98 and winxp, using VFP9 SP1, but I noticed that in w98 produce the following error: "Library file .... is invalid" but in win Xp works fine!!

Atencion: La libreria no funciona en Win98.
Carlos Alarcon
Friday, September 22, 2006 8:05:50 AM (Central Daylight Time, UTC-05:00)
The "library file is invalid" message is caused by not having the proper C++ runtime files for the FLL you are using. In the case of vfpencryption.fll it is the VC++ 8.0 runtimes that are needed, in the case of vfpencryption71.fll it is the VC++ 7.1 runtimes that are needed. It all depends on what version of VC++ the FLL was compiled with. I've written an earlier blog entry regarding a regular expressions fll that includes a section on properly installing the VC++ 8.0 runtimes for it (see "Important note about the required C++ runtime libraries" section at the url below)...

http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,91241006-595a-487d-ac06-d0fc1fc71632.aspx

... in the case of VC++ 7.1 usually you just need the msvcr71.dll and the msvcp71.dll files. This is certainly simpler than having to use the VC++ 8.0 runtimes, and in the case of VFP 9.0 the msvcr71.dll file is already required. However, I prefer to continue moving forward and to use the latest copy of VC++ that has been released from Microsoft.

I hope this information helps. I know that the message that VFP gives is really misleading. It would be so much nicer if it just said, "Unable to load FLL because you're missing the right version of the VC++ runtimes!".
Thursday, April 26, 2007 9:07:41 PM (Central Daylight Time, UTC-05:00)
I cannot begin to tell how useful this was for me to take a pdf file encrypt the file, do filetostr() save the string into a table memo field and when needed to retrieve this client sensitive data, print the decrypted image as its original pdf format. Thank you!
Thursday, May 03, 2007 1:27:16 PM (Central Daylight Time, UTC-05:00)
I have used vfpencryption.fll for over 2 years with out any problems with VFP9. However when installing on a new machine I get a VFP error 2028 Which is the same as not having the VC++ runtime loaded. I down loaded the new version from above with new run time and I still get this error

Have you any ideas how to solve

regards clive
clive homewood
Tuesday, June 26, 2007 7:23:48 PM (Central Daylight Time, UTC-05:00)
He probado y ha funcionado lo que Craig explica en http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,91241006-595a-487d-ac06-d0fc1fc71632.aspx
Simplemente descomprimí el .zip (http://www.sweetpotatosoftware.com/SPSBlog/ct.ashx?id=91241006-595a-487d-ac06-d0fc1fc71632&url=http%3a%2f%2fwww.sweetpotatosoftware.com%2ffiles%2fmicrosoft.vc80.crt.zip) en la misma carpeta donde está ubicada la .fll y anduvo todo perfecto!!! Muchas gracias Craig!!!!.

Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u)  

Enter the code shown (prevents robots):


 

Archive

<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456