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

Duplicate Java's PBEWithMD5AndDES

Demonstrate's how to duplicate Java's PBEWithMD5AndDES.

Download Chilkat Crypt ActiveX

LOCAL loCrypt
LOCAL lnSuccess
LOCAL lcPlainText
LOCAL lcEncryptedText
LOCAL lcDecryptedText

loCrypt = CreateObject('Chilkat.Crypt2')

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

loCrypt.CryptAlgorithm = "pbes1"
loCrypt.PbesPassword = "secret"

loCrypt.PbesAlgorithm = "des"
loCrypt.KeyLength = 64

*  The salt for PBKDF1 is always 8 bytes:
loCrypt.SetEncodedSalt("C773218C7EC8EE99","hex")

loCrypt.IterationCount = 20

*  A hash algorithm needs to be set for PBES1:
loCrypt.HashAlgorithm = "md5"

*  Indicate that the encrypted bytes should be returned
*  as a hex string:
loCrypt.EncodingMode = "hex"

lcPlainText = "This is another example"

lcEncryptedText = loCrypt.EncryptStringENC(lcPlainText)

*  The output should be: E729548140D20B14E9140F832A7E980AA449A84B295C75CE
? lcEncryptedText

*  Now decrypt:

lcDecryptedText = loCrypt.DecryptStringENC(lcEncryptedText)

? lcDecryptedText

*  ----------------------------------------------------------------
*  ----------------------------------------------------------------
*  
The code above duplicates this Java JCE example:

	public static void main(String args[]) throws Exception
	{
	    PBEKeySpec pbeKeySpec;
	    PBEParameterSpec pbeParamSpec;
	    SecretKeyFactory keyFac;

	    // Salt
	    byte[] salt = {
		(byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
		(byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
	    };

	    // Iteration count
	    int count = 20;

	    // Create PBE parameter set
	    pbeParamSpec = new PBEParameterSpec(salt, count);

	    String password = "secret";
	    pbeKeySpec = new PBEKeySpec(password.toCharArray());
	    keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
	    SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

	    // Create PBE Cipher
	    Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");

	    // Initialize PBE Cipher with key and parameters
	    pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);

	    // Our cleartext
	    byte[] cleartext = "This is another example".getBytes();
	    
	    // Encrypt the cleartext
	    byte[] ciphertext = pbeCipher.doFinal(cleartext);
	    
     	System.out.print("ciphertext: ");
        System.out.println(toHex(ciphertext));
	}

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

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