FoxPro Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
Socket
Spider
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Email Object
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
FileAccess
Bzip2
LZW
Icon

 

Non-Chilkat Links
Text and String Handling

AES String Encryption and Decryption

Encrypt and decrypt strings in Visual FoxPro using the Rijndael (AES) encryption algorithm.

***********************************************************
*** Visual FoxPro to AES Encrypt and Decrypt Strings
***********************************************************

LOCAL crypt, keyData, encryptedHexString, decryptedString

crypt = CreateObject('ChilkatCrypt2.ChilkatCrypt2')
crypt.UnlockComponent('Anything for 30-day trial')        

* Tell the encryptor what encryption algorithm to use.
* Rijndael is a synonym for 'AES'.
crypt.CryptAlgorithm = 'aes'

* Set the cipher mode to cbc (this is the default).  The other cipher mode is 'ecb'.
crypt.CipherMode = 'cbc'

* The key length can be 128-bits, 192-bits, or 256-bits.
crypt.KeyLength = 128
    
* Padding Schemes:
* 0((RFC2630) Each padding byte is the pad count (16 extra added if size is already a multiple of 16)
* 1(Random bytes except the last is the pad count (16 extra added if size is already multiple of 16)
* 2(Pad with random data. (If already a multiple of 16, no padding is added).
* 3(Pad with NULLs. (If already a multiple of 16, no padding is added).
* 4(Pad with SPACE chars(0x20). (If already a multiple of 16, no padding is added).
crypt.PaddingScheme = 4
    
* Set the 16-byte initialization vector via a hex encoded string.
* If the IV is not set, it defaults to all '\0' bytes.
crypt.SetEncodedIV('000102030405060708090A0B0C0D0E0F', 'hex')
    
* Set our secret key.  To do this, we hash a password string to a binary secret key
* having the correct bit length (equal to the key length).
keyData = crypt.GenerateSecretKey('This is my password string')
crypt.SecretKey = keyData
    
* Encrypt a string, returning the encrypted data as a hex encoded string.
crypt.EncodingMode = 'hex'

encryptedHexString = crypt.EncryptStringENC('ABCDEFGHIJKLMNOPQRSTUVWXYZ')

* The AES algorithm pads to a 16-byte multiple.  In this example, the 26-byte
* input string is padded to 32 bytes with SPACE characters and encrypted.
* The result is a 64-byte hex string (2 characters per binary byte)
=MESSAGEBOX(encryptedHexString)

* Decrypting is easy...
decryptedString = crypt.DecryptStringENC(encryptedHexString)

* The decrypted string will contain the padding, so it needs to be trimmed.
=MESSAGEBOX(TRIM(decryptedString))

RELEASE crypt

RETURN .T.

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · .NET Email Component · ASP Mail Component · XML Parser