Home | Trees | Index | Help |
---|
Module ezPyCrypto :: Class key |
|
This may well be the only crypto class for Python that you'll ever need. Think of this class, and the ezPyCrypto module, as 'cryptography for the rest of us'.
Designed to strike the optimal balance between ease of use, features and performance.
Basic High-level methods:encString
- encrypt a string
decString
- decrypt a string
encStringToAscii
- encrypt a string to
a printable, mailable format
decStringFromAscii
- decrypt an
ascii-format encrypted string
signString
- produce ascii-format
signature of a string
verifyString
- verify a string against
a signature
importKey
- import public key (and
possibly private key too)
exportKey
- export public key only, as
printable mailable string
exportKeyPrivate
- same, but export
private key as well
makeNewKeys
- generate a new, random
private/public key pair
encStart
- start a stream encryption
session
encNext
- encrypt another piece of
data
encEnd
- finalise stream encryption
session
decStart
- start a stream decryption
session
decNext
- decrypt the next piece of
available data
decEnd
- finalise stream decryption
session
Method Summary | |
---|---|
Constructor. | |
Ends a stream decryption session. | |
Decrypt the next piece of incoming stream data. | |
Start a stream decryption session. | |
Decrypts a previously encrypted string. | |
Decrypts a previously encrypted string in ASCII (base64) format, as created by encryptAscii() | |
Called to terminate a stream session. | |
Encrypt the next piece of data in a stream. | |
Starts a stream encryption session Sets up internal buffers for accepting ad-hoc data. | |
Encrypt a string of data | |
Encrypts a string of data to printable ASCII format | |
Exports the public key as a printable string. | |
Exports public/private key pair as a printable string. | |
Imports a public key or private/public key pair. | |
Creates a new keypair in cipher object, and a new session key | |
Sign a string using private key | |
Encrypts, then decrypts a string. | |
Encrypts, then decrypts a string. | |
Verifies a string against a signature. |
Method Details |
---|
__init__(self,
something=512,
algoPub=None,
algoSess=None,
**kwds)
|
decEnd(self)Ends a stream decryption session. |
decNext(self, chunk)Decrypt the next piece of incoming stream data. Arguments:
|
decStart(self)Start a stream decryption session. Call this method first, then feed in pieces of stream data into decNext until there's no more data to decrypt Arguments:
|
decString(self, enc)Decrypts a previously encrypted string. Arguments:
|
decStringFromAscii(self, enc)Decrypts a previously encrypted string in ASCII (base64) format, as created by encryptAscii() Arguments:
May generate an exception if the public key of the encrypted string doesn't match the public/private keypair in this key object. To work around this problem, either instantiate a key object with the saved keypair, or use the importKey() function. Exception will also occur if this object is not holding a private key (which can happen if you import a key which was previously exported via exportKey(). If you get this problem, use exportKeyPrivate() instead to export your keypair. |
encEnd(self)Called to terminate a stream session. Encrypts any remaining data in buffer. Arguments:
|
encNext(self, raw='')Encrypt the next piece of data in a stream. Arguments:
|
encStart(self)Starts a stream encryption session Sets up internal buffers for accepting ad-hoc data. No arguments needed, nothing returned. |
encString(self, raw)Encrypt a string of data High-level func. encrypts an entire string of data, returning the encrypted string as binary. Arguments:
encStringToAscii instead. The sole
advantage of this method is that it produces more compact data, and
works a bit faster.
|
encStringToAscii(self, raw)Encrypts a string of data to printable ASCII format Use this method instead of This method returns encrypted data in bracketed base64 format, safe for sending in email. Arguments:
|
exportKey(self)Exports the public key as a printable string. Exported keys can be imported elsewhere into MyCipher instances with
the Note that this object contains only the public key. If you want to
export the private key as well, call Note also that the exported string is Base64-encoded, and safe for sending in email. Arguments:
|
exportKeyPrivate(self, **kwds)Exports public/private key pair as a printable string. This string is a binary string consisting of a pickled key object,
that can be imported elsewhere into MyCipher instances with the Note that this object contains the public AND PRIVATE keys. Don't EVER
email any keys you export with this function (unless you know what
you're doing, and you encrypt the exported keys against another key).
When in doubt, use Keep your private keys safe at all times. You have been warned. Note also that the exported string is Base64-encoded, and safe for sending in email. Arguments:
|
importKey(self, keystring, **kwds)Imports a public key or private/public key pair. (as previously exported from this object with the
You don't have to call this if you instantiate your key object in 'import' mode - ie, by calling it with a previously exported key. Note - you shouldn't give a 'passphrase' when importing a public key. |
makeNewKeys(self, keysize=512, **kwds)Creates a new keypair in cipher object, and a new session key Arguments:
Keypair gets stored within the key object. Refer |
signString(self, raw)Sign a string using private key Arguments:
importKey for the right private key first
if needed.
|
test(self, raw)Encrypts, then decrypts a string. What you get back should be the same as what you put in. This is totally useless - it just gives a way to test if this API is doing what it should. |
testAscii(self, raw)Encrypts, then decrypts a string. What you get back should be the same as what you put in. This is totally useless - it just gives a way to test if this API is doing what it should. |
verifyString(self, raw, signature)Verifies a string against a signature. Object must first have the correct public key loaded. (see
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 1.1 on Thu Jul 24 11:15:06 2003 | http://epydoc.sf.net |