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

Match Java JCE AES Encryption Results (ECB mode)

Shows sample code in Visual FoxPro that matches Java JCE encryption results for 128-bit AES encryption using ECB mode.

Download Chilkat Crypt ActiveX

LOCAL loCrypt
LOCAL lnSuccess
LOCAL lcPassword
LOCAL lcSecretKeyHex
LOCAL lcText
LOCAL lcEncText

loCrypt = CreateObject('Chilkat.Crypt2')

* Any string argument automatically begins the 30-day trial.

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

lcPassword = "secretPassphrase"

* Use the Digest MD5 algorithm to get a 16-byte binary secret key.
loCrypt.HashAlgorithm = "md5"
loCrypt.EncodingMode = "hex"

lcSecretKeyHex = loCrypt.HashStringENC(lcPassword)

loCrypt.CryptAlgorithm = "aes"
loCrypt.CipherMode = "ecb"
loCrypt.KeyLength = 128
loCrypt.SetEncodedKey(lcSecretKeyHex,"hex")

lcText = "The quick brown fox jumped over the lazy dog."

lcEncText = loCrypt.EncryptStringENC(lcText)

* Displays:
* C960892077D566258D38DF4BBAE8548E6827BF8C27A9D2EE
* 6F563FC75003F8F6A05B54CFD28CDC8833BD073F7FC6D031
? lcEncText

* This Java (JCE) code produces the same results:
* String password = "secretPassphrase";
* 
* MessageDigest md = MessageDigest.getInstance("MD5");
* md.update(password.getBytes("UTF-8"), 0, password.length());
* byte[] rawKey = md.digest();
* 
* String text = "The quick brown fox jumped over the lazy dog.";
* 
* SecretKeySpec skeySpec = new SecretKeySpec(rawKey, "AES");
* Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
* cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
* 
* byte[] encrypted = cipher.doFinal(text.getBytes("UTF-8"));
* 
* System.out.println(toHex(encrypted));

* This is the toHex method in Java:
* public static String toHex (byte buf[]) {
* 
* StringBuffer strbuf = new StringBuffer(buf.length * 2);
* int i;
* 
* for (i = 0; i < buf.length; i++) {
* if (((int) buf[i] & 0xff) < 0x10)
* strbuf.append("0");
* 
* strbuf.append(Long.toString((int) buf[i] & 0xff, 16));
* }
* 
* return strbuf.toString();
* }

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