# Monday, August 10, 2009

The free vfpencryption71.fll and vfpencryption.fll have been updated. Changes include:

  • Bug fixes for Blowfish encryption (including blocksize and allowing keysize between 8 and 448 bits)
  • Bug fixes to modes CBC and CFB - operate correctly now.
  • Added ability to specify padding, key size, block size, and initialization vector (IV) where applicable (these changes allow compatibility with .NET and other encryption systems as well as the ability to adhere specifically to the AES specification as set out in the FIPS 197 Specification).
  • Added mode OFB to encryption/decryption algorithms.
  • Padding types supported are Zeroes (NULLs), Spaces (blanks), PKCS7, ANSI X.923, and ISO 10126.
  • Added HMAC() function that works with all supported hash types.
  • Added VFP test program files to the downloads that allow developers to see for themselves that return values are correct for various functions provided by the FLL.
  • Added GenerateKey() function that will return a random key or IV based on some specified rules (parameters).
  • Corrected and updated documentation (see below).
Please provide feedback here or send me an email if you run into any problems with this latest version. You'll be able to tell from the test program files (Test Vectors) that I did a lot of testing on my own to make sure that this version was solid. I also did a number of tests between .NET System.Security.Cryptography classes (such as RijndaelManaged for instance) and this FLL to ensure that there was a good deal of compatibility.

The vfpencryption71.fll requires the VC++ 7.1 runtimes whereas the vfpencryption.fll requires the VC++ 9.0 runtimes. If you are getting a "FLL is Invalid" error when running either of these FLLs it is because you are missing the runtimes on the system you are deploying your application on. What about the previous vfpencryption.fll that used the VC++ 8.0 runtimes? I continue to update to the latest Visual Studio (10.0 will be next) and I suggest you do the same. Most VFP developers are using the vfpencryption71.fll as the C runtime matches the one used for VFP 9.0 (msvcr71.dll) and it provides the exact same functionality as vfpencryption.fll. However, I have had numerous requests for an updated build of the FLL using the latest Visual Studio, so I include it below.

Download the Latest Version of the vfpencryption71.fll (134 KB approx.)

Download the Latest Version of the vfpencryption.fll (142 KB approx.)



vfpencryption71.fll/vfpencryption.fll Documentation...

Function ENCRYPT()

Signature: Encrypt(cStringtoEncrypt, cSecretKey[, nEncryptionType[, nEncryptionMode[, nPaddingType[, nKeySize[, nBlockSize[, cIV]]]]]])

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 = Rijndael\AES 128 (requires a 16 character Key)
1 = Rijndael\AES 192 (requires a 24 character Key)
2 = Rijndael\AES 256 (requires a 32 character Key) *Default
4 = Blowfish (key between 1 and 56 characters)
8 = TEA (requires a 16 character Key)
1024 = RC4 (Key can be any length)

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), Cipher Feedback Block (CFB), and Output Feedback Block. The nEncryptionMode parameter does not apply to RC4 encryption (nEncryptionType = 1024).

0 = ECB *Default
1 = CBC
2 = CFB
3 = OFB

nPaddingMode - For Block Ciphers the cStringtoEncrypt is padded to a multiple of the block size for the algorithm. Setting this parameter allows you to specify how this padding is done.

0 = Zeroes (NULLs) *Default
1 = Spaces (blanks)
2 = PKCS7
3 = ANSI X.923
4 = ISO 10126

nKeySize - The size of the cSecretKey in bytes (characters).

nBlockSize - The block size the nEncryptionType should use.

cIV - The Initialization Vector (IV) that should be used for CBC, CFB, and OFB modes should use. This IV should match the specified nBlockSize in total bytes (characters).

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. This does not apply when using RC4 encryption (nEncryptionType = 1024).


Function DECRYPT()

Signature: Decrypt(cEncryptString, cSecretKey[, nDecryptionType[, nDecryptionMode[, nPaddingType[, nKeySize[, nBlockSize[, cIV]]]]]])

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 = Rijndael\AES 128 (requires a 16 character Key)
1 = Rijndael\AES 192 (requires a 24 character Key)
2 = Rijndael\AES 256 (requires a 32 character Key) *Default
4 = Blowfish (key between 1 and 56 characters)
8 = TEA (requires a 16 character Key)
1024 = RC4 (Key can be any length) 

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), Cipher Feedback Block (CFB), and Output Feedback Block. The nDecryptionMode parameter does not apply to RC4 decryption (nDecryptionType = 1024).

0 = ECB *Default
1 = CBC
2 = CFB
3 = OFB

nPaddingMode - For Block Ciphers the cStringtoEncrypt is padded to a multiple of the block size for the algorithm. Setting this parameter allows you to specify how this padding is done.

0 = Zeroes (NULLs) *Default
1 = Spaces (blanks)
2 = PKCS7
3 = ANSI X.923
4 = ISO 10126

nKeySize - The size of the cSecretKey in bytes (characters).

nBlockSize - The block size the nEncryptionType should use.

cIV - The Initialization Vector (IV) that should be used for CBC, CFB, and OFB modes should use. This IV should match the specified nBlockSize in total bytes (characters).

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(). This does not apply when using RC4 decryption (nDecryptionType = 1024).



Function ENCRYPTFILE()

Signature: EncryptFile(cFiletoEncrypt, cDestinationFile, cSecretKey[, nEncryptionType[, nEncryptionMode[, nPaddingType[, nKeySize[, nBlockSize[, cIV]]]]]])

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 = Rijndael\AES 128 (requires a 16 character Key)
1 = Rijndael\AES 192 (requires a 24 character Key)
2 = Rijndael\AES 256 (requires a 32 character Key) *Default
4 = Blowfish (key between 1 and 56 characters)
8 = TEA (requires a 16 character Key)
1024 = RC4 (Key can be any length) 

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), Cipher Feedback Block (CFB), and Output Feedback Block. This does not apply when using RC4 encryption (nEncryptionType = 1024).

0 = ECB *Default
1 = CBC
2 = CFB
3 = OFB

nPaddingMode - For Block Ciphers the cStringtoEncrypt is padded to a multiple of the block size for the algorithm. Setting this parameter allows you to specify how this padding is done.

0 = Zeroes (NULLs) *Default
1 = Spaces (blanks)
2 = PKCS7
3 = ANSI X.923
4 = ISO 10126

nKeySize - The size of the cSecretKey in bytes (characters).

nBlockSize - The block size the nEncryptionType should use.

cIV - The Initialization Vector (IV) that should be used for CBC, CFB, and OFB modes should use. This IV should match the specified nBlockSize in total bytes (characters).

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[, nPaddingType[, nKeySize[, nBlockSize[, cIV]]]]]])

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 = Rijndael\AES 128 (requires a 16 character Key)
1 = Rijndael\AES 192 (requires a 24 character Key)
2 = Rijndael\AES 256 (requires a 32 character Key) *Default
4 = Blowfish (key between 1 and 56 characters)
8 = TEA (requires a 16 character Key)
1024 = RC4 (Key can be any length) 

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), Cipher Feedback Block (CFB), and Output Feedback Block. This does not apply when using RC4 decryption (nDecryptionType = 1024).

0 = ECB *Default
1 = CBC
2 = CFB
3 = OFB

nPaddingMode - For Block Ciphers the cStringtoEncrypt is padded to a multiple of the block size for the algorithm. Setting this parameter allows you to specify how this padding is done.

0 = Zeroes (NULLs) *Default
1 = Spaces (blanks)
2 = PKCS7
3 = ANSI X.923
4 = ISO 10126

nKeySize - The size of the cSecretKey in bytes (characters).

nBlockSize - The block size the nEncryptionType should use.

cIV - The Initialization Vector (IV) that should be used for CBC, CFB, and OFB modes should use. This IV should match the specified nBlockSize in total bytes (characters).

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 = RIPEMD160

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


Function HASHFILE()

Signature: HashFile(cFileName[, nHashType])

Parameters:

cFileName - The fullpath and name of an existing file you wish to generate a message digest for

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 =
RIPEMD160

Return Value:

Binary Character Data - the hash for cFileName.

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 HashFile() function and sending it in as a parameter to the STRCONV() function. For example:

?STRCONV(HashFile("C:\MyFile.txt"), 15) && hexBinary Hash


Function HASHRECORD()

Signature: HashRecord(cAlias[, nHashType[,lIncludeMemos]])

Parameters:

cAlias - The table alias containing the record to be 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 =
RIPEMD160

lIncludeMemos - Flag determining whether Memo fields should be included when generating the message digest. .T. = Include Memo Fields, .F. = Exclude Memo Fields

Return Value:

Binary Character Data - the hash for the current record in cAlias.

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 HashRecord() function and sending it in as a parameter to the STRCONV() function. For example:

?STRCONV(HashRecord("MyTable",5,.T.), 15) && hexBinary Hash


Function HMAC()

Signature: HMAC(cStringtoHash, cSecretKey[, nHashType])

Parameters:

cStringtoHash - A plain text string you wish to have a keyed Hash Message Authentication Code (HMAC) generated from.

cSecretKey - A plain text string that is the Key you want used during generation of the keyed HMAC.

nHashType - The type of hash function to use when generating the keyed HMAC. 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 = RIPEMD160

Return Value:

Binary Character Data - the HMAC for the given cStringtoHash and cSecretKey.

Remarks:

The HMAC is returned as a series of binary characters. However, it is more common to see HMACs in a hexBinary format. This can be accomplished in Visual FoxPro by taking the return of the HMAC() function and sending it in as a parameter to STRCONV(cReturn, 15).


Function CRC()

Signature: CRC(cExpression[, nCRCType])

Parameters:

cExpression - The string you wish to have a CRC generated for

nCRCType - The type of CRC to generate. There are currently 2 different CRC types supported

1 = 16-bit
2 = 32-bit

Return Value:

Numeric Data - the CRC for cExpression.

Remarks:

The CRC that is returned is unsigned, which means that the returned 16-bit CRC needs to be treated as a 4 Byte numeric value and the 32-bit CRC as a 8 byte numeric value in Visual FoxPro. The operation of the CRC() function presented here is quite similar to Visual FoxPro's Sys(2007) function, however you will find that creation of 32-bit CRCs is much faster using this function.


Function CRCFILE()

Signature: CRCFile(cFileName[, nCRCType])

Parameters:

cFileName - The fullpath and name of an existing file you wish to generate a CRC for

nCRCType - The type of CRC to generate. There are currently 2 different CRC types supported

1 = 16-bit
2 = 32-bit

Return Value:

Numeric Data - the CRC for cFileName.

Remarks:

The CRC that is returned is unsigned, which means that the returned 16-bit CRC needs to be treated as a 4 Byte numeric value and the 32-bit CRC as a 8 byte numeric value in Visual FoxPro.


Function CRCRECORD()

Signature: CRCRecord(cAlias[, nCRCType[,lIncludeMemos]])

Parameters:

cAlias - The table alias containing the record to be hashed

nCRCType - The type of CRC to generate. There are currently 2 different CRC types supported

1 = 16-bit
2 = 32-bit

lIncludeMemos - Flag determining whether Memo fields should be included when generating the message digest. .T. = Include Memo Fields, .F. = Exclude Memo Fields

Return Value:

Numeric Data - the CRC for the current record in cAlias .

Remarks:

The CRC that is returned is unsigned, which means that the returned 16-bit CRC needs to be treated as a 4 Byte numeric value and the 32-bit CRC as a 8 byte numeric value in Visual FoxPro. The operation of the CRC() function presented here is quite similar to Visual FoxPro's Sys(2017) function, however you will find that this CRC function is faster than Visual FoxPro's Sys(2017). Also, this function allows you to specify a table alias, which allows CRCs to be created for a record in a table other than the currently selected work area. On the downside, this function does not allow you to specify a comma delimited list of fields to exclude like Sys(2017) does.


Function GENERATEKEY()

Signature: GenerateKey(nKeySize[, lIncludeNumbers[, lIncludeUpper[, lIncludeSpecial]]])

Parameters:

nKeySize - The size of the key to be returned in bytes (total characters you want returned)

lIncludeNumbers -
Flag determining whether Numbers (digits "0-9") should be included when generating the key. .T. = Include Numbers, .F. = Exclude Numbers (default)

lIncludeUpper - Flag determining whether uppercase characters should be included when generating the key. .T. = Include Uppercase Characters, .F. = Exclude Uppercase Characters (default)

lIncludeSpecial - Flag determining whether Special Characters (characters "{}|\\]?[\":;'><,./~!@#$%^&*()_+`-=") should be included when generating the key. .T. = Include Special Characters, .F. = Exclude Special Characters (default)

Return Value:

Character Data - the random key generated based on the specified rules.

Remarks:

The key generated is a random set of lowercase characters by default. To add additional possible characters for generating the key you can use the parameters (2-4) as specified. The random keys returned can be used for the other FLL functions that allow for a cSecretKey or cIV. This function is provided as a convenience function for developers needing to produce a random key quickly and easily.


Monday, August 10, 2009 12:16:26 AM (GMT Daylight Time, UTC+01:00)  #    Comments [17]
Monday, August 10, 2009 4:23:24 PM (GMT Daylight Time, UTC+01:00)
Thanks Craig! It's great that you are able to continue supporting and extending your fine set of utilities.
Wednesday, August 12, 2009 9:38:27 AM (GMT Daylight Time, UTC+01:00)
Thanks Craig,

I will download this and test with sending / receiving encrypted text from .Net. I struggled with the previous version due to "Salt".
Stephen Wileman
Saturday, August 22, 2009 12:29:02 AM (GMT Daylight Time, UTC+01:00)
Hi there

First let me say thanks for providing such a great utility for free.

I'm using HMAC-SHA256 to calculate a signature for Amazon Web Services, Product Advertising side, but can't succeed in calculating the correct key for the example they give, which makes me think I'm doing something wrong.

The string to sign is:

GET
webservices.amazon.com
/onca/xml
AWSAccessKeyId=00000000000000000000&ItemId=0679722769&Operation=I
temLookup&ResponseGroup=ItemAttributes%2COffers%2CImages%2CReview
s&Service=AWSECommerceService&Timestamp=2009-01-01T12%3A00%3A00Z&
Version=2009-01-06

with a secret key of 1234567890

They give a correct signature of Nace+U3Az4OhN7tISqgs1vdLBHBEijWcBeCqL5xN9xg= (in encoded Base64), whereas I get a value of D3aBidvveNxQH8mR6tTElQ3ivQAf9/6zBO5urN/0JPw= after putting the result of the function through STRCONV()

I stored the string above as:

lcAmazonString = "GET" + CHR(13) + ;
"webservices.amazon.com" + CHR(13) + ;
"/onca/xml" + CHR(13) + ;
"AWSAccessKeyId=00000000000000000000&ItemId=0679722769&Operation=I" + ;
"temLookup&ResponseGroup=ItemAttributes%2COffers%2CImages%2CReview" + ;
"s&Service=AWSECommerceService&Timestamp=2009-01-01T12%3A00%3A00Z&" + ;
"Version=2009-01-06"

with the key as lcSecretKey = "1234567890"

I've tried all I can think of to make the signatures match to no avail. If you can see something wrong here I'd be very grateful to hear about it.

Thanks again and in advance

John
John Barrie
Saturday, August 22, 2009 8:04:02 PM (GMT Daylight Time, UTC+01:00)
Hey Craig - just writing back to say that Olaf on Foxite gave me the answer - use CHR(10) instead of CHR(13). Everything's working great now and I'm very glad that you took the time to put this library together.

Cheers!!!

John
John Barrie
Sunday, August 23, 2009 1:29:18 AM (GMT Daylight Time, UTC+01:00)
Glad to hear you got it sorted out John. Thanks Olaf in case you're reading this.
Tuesday, August 25, 2009 6:51:38 PM (GMT Daylight Time, UTC+01:00)
Hi Craig,

I am having difficulty using vfpencryption.fll as part of a web service.

The HASH method works OK, but the DECRYPT method causes an ERROR 2028, which indicates I am not passing in the correct parameters. However the same code works fine run as a .exe.

I have tried passing a full set of parameters (including optional parameters).

Any ideas would be much appreciated.

Thanks
Steve
Stephen Wileman
Wednesday, August 26, 2009 2:52:21 AM (GMT Daylight Time, UTC+01:00)
Stephen, can you tell me what values you are passing for each parameter so I can reproduce the problem? Just give me some code that reproduces this and I'll take a look. Thanks.
Thursday, August 27, 2009 6:24:27 PM (GMT Daylight Time, UTC+01:00)
Hi Craig,

Ignore my post. I hadn't realised that when using the Task Pane in VFP to test the web service it was truncating the string I cut 'n' paste into it.

Thanks for getting back to me.

Steve
Stephen Wileman
Tuesday, September 15, 2009 10:42:12 PM (GMT Daylight Time, UTC+01:00)
I'm having issues with this and management is making getting this fixed a priority.

I have updated to your latest version from August.

In runtime (VFP9 SP1) I get a "data type mismatch" error when I call the decrypt function. With the older version I could run in development with no issues. With the new version (and the new version of the 71.fll) I get "API Call caused an exception".

Encryption works fine.

Any pointers or suggestions would be helpful.

Thanks

Alan

Here is the code where I call the decryption function. (No thats not the real key ;) )
lcPassKey=[<Super Duper Secret Key goes here>]
WAIT WINDOW [1 --> ]+lcDecrypt+[<--]
lcDecrypt = Decrypt(lcDecrypt,lcPassKey , 1, 0)
WAIT WINDOW [2 --> ]+lcDecrypt+[<--]

Alan
Wednesday, September 16, 2009 3:35:31 PM (GMT Daylight Time, UTC+01:00)
An update for anyone interested. It seems I only generate the API error on decrypt if I pass an unencrypted string in.

Alan
Thursday, September 17, 2009 11:46:28 PM (GMT Daylight Time, UTC+01:00)
I found the root cause of my issue.

IN my app that does the decryption UDFParms is set to "reference" for this function to work UDFParms must be set to by "value". I'm willing to bet that is the same for all functions here. I did not know my decrypt app had been set to reference.

(I thougth I posted this yesterday but its missing. )
Alan
Tuesday, October 06, 2009 7:22:47 PM (GMT Daylight Time, UTC+01:00)
Dear Sir,

Can Encrypt VFP exe with vfpencryption utility if this possible then how.


THAnKS
Wednesday, October 07, 2009 2:56:03 PM (GMT Daylight Time, UTC+01:00)
Possible bug (or at least worth a comment in the documentation if not a bug)...

When using the EncryptFile() DecryptFile() functions on a VFP table the resulting decrypted table is 'not a table' if the filename(s) used in the process start with a number.

Specifically, I used encryption type 1024 with a 32 bit key against a Fox2x type database with no index. Since it worked fine in tests against some standard tables I couldn't figure out why it didn't work in a compiled EXE - the only difference I could see was the file naming scheme. Changing the naming scheme to not use numbers at the start of the filename worked.
Steven Supinski
Thursday, October 08, 2009 10:15:05 PM (GMT Daylight Time, UTC+01:00)
The filename of the encrypted table wasn't really the cause of my problem. Turns out it's a codepage issue. I hate codepages...

Make sure that the 'default' codepage when you decrypt matches what it was when you encrypted that table. I'm jumping between 437/1252 tables and in this instance two different applications whose defaults happen to be the opposite of each other.

Tuesday, November 17, 2009 10:17:47 AM (GMT Standard Time, UTC+00:00)
Hello.

I have a problem with using this library...

When I run this code:

SET LIBRARY TO (LOCFILE("vfpencryption.fll","FLL"))
m.lcPlainText = STRCONV("Testing encryption...",16)
m.lcKey = "2b7e151628aed2a6abf7158809cf4f3c"
?Encrypt(m.lcPlainText, STRCONV(m.lcKey,16), 0, 0, 0, 16, 16)

I get output:

cb - I stripped byte characters here that Simon had posted. It seemed to be screwing up comments for this blog entry.

I use VFP 9.0 SP1.

What could be wrong? Thanks for help.
Simon Novak
Tuesday, March 02, 2010 5:14:55 PM (GMT Standard Time, UTC+00:00)
Hello,

my Problem seems to concern Windows 7 und Server 2008 R2: decryptfile does not work, i got an "API Call caused an exception" ! With Window XP everything was fine. I switched to filetostr / decrypt / strtofile to handle this error.

Best Regards
Bodo van Rueschen
Saturday, March 06, 2010 8:39:37 PM (GMT Standard Time, UTC+00:00)
Thanks for this great library.

crcrecord ignores BLOB memo fields.
Jorge Fernandez
All comments require the approval of the site owner before being displayed.
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, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview

 

Archive

<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910