The Artima Developer Community
Sponsored Link

Python Buzz Forum
Easy Python Cryptography

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Simon Willison

Posts: 282
Nickname: simonw
Registered: Jun, 2003

Simon Willison is a web technology enthusiast studying for a Computer Science degree at Bath Uni, UK
Easy Python Cryptography Posted: Jul 1, 2003 4:09 PM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Simon Willison.
Original Post: Easy Python Cryptography
Feed Title: Simon Willison: Python
Feed URL: http://simon.incutio.com/syndicate/python/rss1.0
Feed Description: Simon Willison's Python cateory
Latest Python Buzz Posts
Latest Python Buzz Posts by Simon Willison
Latest Posts From Simon Willison: Python

Advertisement

Via Garth Kidd's Python cryptography roundup, ezPyCrypto is a cryptography API so simple even I can use it. Unfortunately the example code is only available in the download archive (not on the web site) but here's an overview of how it works:

import ezPyCrypto
# Generate a 512 bit key
key = ezPyCrypto.key(512)

text = 'This will be encrypted'

# Encrypt the string
encrypted = key.encString(text)
print encrypted

# Unencrypt the string
decrypted = key.decString(encrypted)
print decrypted

# Export the public key
public = key.exportKey()
# This can now be saved or distributed

# Export the private key
private = key.exportKeyPrivate()
# This can now be saved somewhere safe

# Encrypting using an already generated public key:
key = ezPyCrypto.key()
key.importKey(public)
encrypted = key.encString(text)

# Decrypting using an already generated private key:
key = ezPyCrypto.key()
key.importKey(private)
decrypted = key.decString(text)

That's pretty much it. The class also has support for passphrases which can be used to add an extra layer of protection to a private key, as well as methods to handle crypotgraphic signing and verification.

ezPyCrypto is an easy to use wrapper for the excellent PyCrypto module, and includes PyCrypto (and a handy Windows installer) in the distribution.

Read: Easy Python Cryptography

Topic: Threads Previous Topic   Next Topic Topic: Deja vu

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use