Python Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Python Examples

Quick Start
Python Unicode
Python Byte Array
Python Certs
Python Email
Python Encryption
Python FTP
HTML-to-XML
Python HTTP
Python IMAP
Python MHT
Python MIME
Python RSA
Python S/MIME
Python Signatures
Python Socket
Python Spider
Python Tar
Python Upload
Python XML
Python XMP
Python Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

 

AES Encryption in CBC Mode, w/ Initialization Vector, PKCS5 Padding

Demonstrates encrypting a string in Python using AES encryption and encoding the resultant binary encrypted data in a base64 string.

Download Python Programming Example Scripts

# file: aesEncrypt.py

import chilkat 

# Python AES Encryption Example Script
crypt = chilkat.CkCrypt2()
crypt.UnlockComponent("anything for 30-day trial")
    
crypt.put_CryptAlgorithm("aes")
# Use cipher block chaining (CBC) mode
crypt.put_CipherMode("cbc")
# Use 128-bit encryption
crypt.put_KeyLength(128)
# Set the initialization vector.
crypt.SetEncodedIV("000102030405060708090A0B0C0D0E0F","hex")
# Set the secret key.
crypt.SetEncodedKey("000102030405060708090A0B0C0D0E0F","hex")
# Encoding the encrypted bytes in base64
crypt.put_EncodingMode("base64")
# Use the default padding scheme (PKCS5 Padding)
crypt.put_PaddingScheme(0)

encryptedStr = chilkat.CkString()
crypt.EncryptStringENC("Hello World!",encryptedStr)

# Output is: qiq+IFhcjTkEIkZyf31V/g==
print "Encrypted: " + encryptedStr.getString() + "\n"

decryptedStr = chilkat.CkString()
crypt.DecryptStringENC(encryptedStr.getString(),decryptedStr)

print "Decrypted: " + decryptedStr.getString() + "\n"






 

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

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