Python Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Python Examples

Quick Start
Unicode
Byte Array
Bz2
Certificates
CSV
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT
MIME
POP3
RSA
S/MIME
Signatures
Socket / SSL
SFTP
SMTP
Spider
SSH Key
SSH
SSH Tunnel
Tar
HTTP Upload
XML
XMP
Zip

More Examples...
String
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

 

AES String Encryption

AES string encryption in Python.

Download Chilkat Python 2.5 Library

Download Chilkat Python 2.6 Library

Download Chilkat Python 2.6 Library (x64)

import sys
import chilkat

crypt = chilkat.CkCrypt2()

success = crypt.UnlockComponent("Anything for 30-day trial")
if (success != True):
    print "Crypt component unlock failed"
    sys.exit()

password = "secretPassPhrase"

crypt.put_CryptAlgorithm("aes")
crypt.put_CipherMode("cbc")
crypt.put_KeyLength(128)

#  Generate a binary secret key from a password string
#  of any length.  For 128-bit encryption, GenEncodedSecretKey
#  generates the MD5 hash of the password and returns it
#  in the encoded form requested.  The 2nd param can be
#  "hex", "base64", "url", "quoted-printable", etc.
hexKey = crypt.genEncodedSecretKey(password,"hex")
crypt.SetEncodedKey(hexKey,"hex")

crypt.put_EncodingMode("base64")
text = "The quick brown fox jumped over the lazy dog."

#  Encrypt a string and return the binary encrypted data
#  in a base-64 encoded string.
encText = crypt.encryptStringENC(text)

print encText

#  Decrypt and show the original string:
decryptedText = crypt.decryptStringENC(encText)

print decryptedText
 

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

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