FoxPro Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

Visual FoxPro Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
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...
Amazon S3
DKIM / DomainKey
NTLM
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA
FileAccess
Bzip2
LZW

 

Non-Chilkat Links
Text and String Handling

File Encryption / Decryption

Download Chilkat Crypt ActiveX

File-to-file encryption in Visual FoxPro using AES, Blowfish, RC2, ARC4, or 3DES.

LOCAL loCrypt
LOCAL lnSuccess
LOCAL lcKey
LOCAL lcIv

loCrypt = CreateObject('Chilkat.Crypt2')

lnSuccess = loCrypt.UnlockComponent("Anything for 30-day trial")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX("Crypt component unlock failed")
    QUIT
ENDIF

loCrypt.CryptAlgorithm = "aes"
loCrypt.CipherMode = "cbc"
loCrypt.KeyLength = 128

*  16 bytes of key for 128-bit encryption.
lcKey = "1234567890123456"

*  The IV is equal to the block size of the encryption algorithm.

lcIv = "1234567890123456"

*  Set the key.
loCrypt.SetEncodedKey(lcKey,"ascii")

*  Set the IV
loCrypt.SetEncodedIV(lcIv,"ascii")

*  AES Encrypt the file (the file may be any size because it will
*  stream the file in/out.
lnSuccess = loCrypt.CkEncryptFile("hamlet.xml","aesEncrypted.dat")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

*  AES Decrypt the file (the file may be any size because it will
*  stream the file in/out.
lnSuccess = loCrypt.CkDecryptFile("aesEncrypted.dat","hamlet_aes.xml")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

=MESSAGEBOX("AES File Encryption Success.")

*  Now do 3DES file encryption:

*  To use Triple-DES, set the algorithm = "des",
*  and the key length = 168.
*  To use DES, set the key length = 56 bits.
loCrypt.CryptAlgorithm = "des"
loCrypt.CipherMode = "cbc"
loCrypt.KeyLength = 168

*  3DES Encrypt the file
lnSuccess = loCrypt.CkEncryptFile("hamlet.xml","tripleDesEncrypted.dat")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

*  3DES Decrypt the file
lnSuccess = loCrypt.CkDecryptFile("tripleDesEncrypted.dat","hamlet_3des.xml")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

=MESSAGEBOX("3DES File Encryption Success.")

*  Do Blowfish file encryption:

*  To use Blowfish, set the algorithm = "blowfish2".
*  The original Chilkat "blowfish" implementation outputs
*  4321 swapped bytes.  "blowfish2" output is in the correct
*  byte order.
loCrypt.CryptAlgorithm = "blowfish2"
loCrypt.CipherMode = "cbc"
loCrypt.KeyLength = 128

*  Blowfish Encrypt the file
lnSuccess = loCrypt.CkEncryptFile("hamlet.xml","blowfishEncrypted.dat")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

*  Blowfish Decrypt the file
lnSuccess = loCrypt.CkDecryptFile("blowfishEncrypted.dat","hamlet_blowfish.xml")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

=MESSAGEBOX("Blowfish File Encryption Success.")

*  Do RC2 file encryption:

*  To use RC2, set the algorithm = "rc2".
*  Also, set the Rc2EffectiveKeyLength property.
loCrypt.CryptAlgorithm = "rc2"
loCrypt.CipherMode = "cbc"
*  Key length and effective key length should range
*  from 8 to 1024 bits.
loCrypt.KeyLength = 128
loCrypt.Rc2EffectiveKeyLength = 128

*  RC2 Encrypt the file
lnSuccess = loCrypt.CkEncryptFile("hamlet.xml","rc2Encrypted.dat")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

*  RC2 Decrypt the file
lnSuccess = loCrypt.CkDecryptFile("rc2Encrypted.dat","hamlet_rc2.xml")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

=MESSAGEBOX("RC2 File Encryption Success.")

*  Do ARC4 file encryption:

*  To use ARC4, set the algorithm = "arc4".
loCrypt.CryptAlgorithm = "arc4"
loCrypt.KeyLength = 128

*  ARC4 Encrypt the file
lnSuccess = loCrypt.CkEncryptFile("hamlet.xml","arc4Encrypted.dat")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

*  ARC4 Decrypt the file
lnSuccess = loCrypt.CkDecryptFile("arc4Encrypted.dat","hamlet_arc4.xml")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

=MESSAGEBOX("ARC4 File Encryption Success.")


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

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