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
DKIM / DomainKey
NTLM
RSS
Atom
Byte Array
Service
PPMD
Deflate
DH Key Exchange
DSA
FileAccess
Bzip2
LZW

 

Non-Chilkat Links
Text and String Handling

Encrypt File to .p7m

Download Chilkat Crypt ActiveX

Visual FoxPro example program to encrypt a file to produce a .p7m as output. A digital certificate (public-key) is used for encrypting.

LOCAL loCrypt
LOCAL lnSuccess
LOCAL loCert


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

*  Use public-key encryption with a digital certificate:
loCrypt.CryptAlgorithm = "pki"

*  There are many ways to select and load a digital certificate.
*  Certs can be retrieved from the Windows registry-based
*  certificate stores, from database tables, files, etc.
*  This example will load a .cer file.
loCert = CreateObject('Chilkat.Cert')

lnSuccess = loCert.LoadFromFile("myCert.cer")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCert.LastErrorText)
    QUIT
ENDIF

loCrypt.SetEncryptCert(loCert)

*  The CkEncryptFile can encrypt files of any size.  The
*  encryption occurs in streaming mode, so it is not necessary
*  to hold the entire contents of the file in memory at once.
lnSuccess = loCrypt.CkEncryptFile("dude.gif","dude.p7m")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF

*  To decrypt the file, you'll need the private key.
*  Also, the certificate should have already been installed
*  on the computer.  This is typically achieved by installing
*  from a .pfx file, or by importing from a certificate
*  authority's online web application.  If you are decrypting
*  from ASP, ASP.NET, or a Windows Service, you'll need to
*  import in a way that provides the calling process permission
*  to access and use the private key.  The procedure for
*  doing this is explained here:
*  http://blog.chilkatsoft.com/?p=149
* 
*  Also, there is no "SetDecryptCert" method.  The .p7m
*  contains information that allows the Chilkat component
*  to locate the certificate to be used for decryption.
*  The Chilkat Crypt component automatically searches
*  the Windows Current User certificate store and the
*  Local Machine certificate store.
lnSuccess = loCrypt.CkDecryptFile("dude.p7m","dudeOut.gif")
IF (lnSuccess <> 1) THEN
    =MESSAGEBOX(loCrypt.LastErrorText)
    QUIT
ENDIF


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

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

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