1 from blockcipher
import *
2 import Crypto
.Cipher
.DES
4 def new(key
,mode
=MODE_ECB
,IV
=None,counter
=None):
5 """Create a new cipher object
7 DES using pycrypto for algo and pycryptoplus for ciphermode
9 key = raw string containing the keys
10 mode = python_AES.MODE_ECB/CBC/CFB/OFB/CTR/CMAC, default is ECB
11 IV = IV as a raw string
12 -> only needed for CBC mode
13 counter = counter object (CryptoPlus.Util.util.Counter)
14 -> only needed for CTR mode
20 >>> from CryptoPlus.Cipher import DES
22 EXAMPLE (test vectors from NESSIE):
23 -----------------------------------
25 >>> cipher = DES.new(('7CA110454A1A6E57').decode('hex'))
26 >>> ciphertext = cipher.encrypt(('01A1D6D039776742').decode('hex'))
27 >>> (ciphertext).encode('hex')
29 >>> plaintext = cipher.decrypt(ciphertext)
30 >>> (plaintext).encode('hex')
34 return DES(key
,mode
,IV
,counter
)
36 class DES(BlockCipher
):
37 def __init__(self
,key
,mode
,IV
,counter
):
38 cipher_module
= Crypto
.Cipher
.DES
.new
40 BlockCipher
.__init
__(self
,key
,mode
,IV
,counter
,cipher_module
)
46 if __name__
== "__main__":