IMPORTANT: The functions within this FLL have changed. Please refer to the latest documention for the VFP Encryption FLL that can be found at the following link:
Major VFP Encryption Update
http://en.wikipedia.org/wiki/AES
Description of the new Visual FoxPro AES Encryption FunctionsFunction SignaturesAesEncrypt(cString, cKey, [nMode, [nKeySize]])AesDecrypt(cString, cKey, [nMode, [nKeySize]])ParameterscString: String to encrypt/decryptcKey: Encryption Key to use (16, 24, or 32 characters depending on nKeySize)*nMode: AES Mode (1 = ECB 2 = CBC)nKeySize: Size of Key in bits (128, 192, 256)* The cKey parameter will accept keys that aren't the right size and either pad or truncate them in order to provide the internal FLL function with the correct key length, however this weakens the overall security of the AES encryption and is strongly discouraged.
Download the FLL and Start Using AES in Visual FoxProHere is the download link and some cut-paste-and-execute sample code so you can try it out. NOTE: I will be overwriting prior versions of the fll so the links always point to the latest version. Also, should you want to see a specific cipher or hash implemented in this FLL, or if you have some other suggestions/ideas, please feel free to leave me a comment about it and I will see what I can do.
Download the VFP Encryption FLL (22 KB approx.)
Example of UseCLEARSET LIBRARY TO LOCFILE("vfpencryption.fll")#DEFINE ASECRET256BITKEY "LVE*(zz}}'rr)`P%wDq@lc8WWbGw0[77" && Example only, make your own 32 character key? "__________________________"? "EXAMPLE #1 (simplest): USES DEFAULT AES - CBC MODE 256-BIT KEY"cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET256BITKEY)cDecryptedString = AesDecrypt(cEncryptedString, ASECRET256BITKEY)? "Encrypted: " + cEncryptedString? "Decrypted: " + cDecryptedString? "__________________________"? "EXAMPLE #2: USES AES - ECB MODE 256-BIT KEY"cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET256BITKEY, 1, 256)cDecryptedString = AesDecrypt(cEncryptedString, ASECRET256BITKEY, 1, 256)? "Encrypted: " + cEncryptedString? "Decrypted: " + cDecryptedString? "__________________________"? "EXAMPLE #3: USES AES - CBC MODE 256-BIT KEY"cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET256BITKEY, 2, 256)cDecryptedString = AesDecrypt(cEncryptedString, ASECRET256BITKEY, 2, 256)? "Encrypted: " + cEncryptedString? "Decrypted: " + cDecryptedString? "__________________________"#DEFINE ASECRET192BITKEY "!rPrrj<t!fr7$7L?1#\\;lAV" && Example only, make your own 24 character key? "EXAMPLE #4: USES AES - ECB MODE 192-BIT KEY"cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET192BITKEY, 1, 192)cDecryptedString = AesDecrypt(cEncryptedString, ASECRET192BITKEY, 1, 192)? "Encrypted: " + cEncryptedString? "Decrypted: " + cDecryptedString? "__________________________"? "EXAMPLE #5: USES AES - CBC MODE 192-BIT KEY"cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET192BITKEY, 2, 192)cDecryptedString = AesDecrypt(cEncryptedString, ASECRET192BITKEY, 2, 192)? "Encrypted: " + cEncryptedString? "Decrypted: " + cDecryptedString? "__________________________"#DEFINE ASECRET128BITKEY "!rPrrj<t!fr7$7L?1#\\;lAV" && Example only, make your own 16 character key? "EXAMPLE #6: USES AES - ECB MODE 128-BIT KEY"cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET128BITKEY, 1, 128)cDecryptedString = AesDecrypt(cEncryptedString, ASECRET128BITKEY, 1, 128)? "Encrypted: " + cEncryptedString? "Decrypted: " + cDecryptedString? "__________________________"? "EXAMPLE #7: USES AES - CBC MODE 128-BIT KEY"cEncryptedString = AesEncrypt("Visual FoxPro Rocks!", ASECRET128BITKEY, 2, 128)cDecryptedString = AesDecrypt(cEncryptedString, ASECRET128BITKEY, 2, 128)? "Encrypted: " + cEncryptedString? "Decrypted: " + cDecryptedString
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u