1. Encryption:
pydes.des (key, [mode], [IV], [pad], [Padmode]) Pydes.triple_des (key, [mode], [IV], [pad], [padmode]) key-Bytes containing the encryption key. 8 bytes forDES, 16or24bytes forTriple DesmodeOptional argument forencryption type, can is either PYDES.ECB (Electronic Code book)orPYDES.CBC (Cypher Block Chaining) IV-Optional Initial Value bytes, must be suppliedifusing CBC mode. Length must be8Bytes.pad-Optional argument, set the pad character (Pad_normal) to use during all encrypt/decrpt Operations done with this Instance.padmode-Optional argument, set the padding mode (pad_normalorPAD_PKCS5) to use during all encrypt/DECRPT operations done with this instance.
Instance:
Example------- fromPydesImport*Data="Please encrypt my data"k= des ("Descrypt"Cbc"\0\0\0\0\0\0\0\0", Pad=none, padmode=pad_pkcs5)#For Python3, you'll need to use bytes, i.e.:#data = B "Please encrypt my data"#k = des (b "descrypt", CBC, B "\0\0\0\0\0\0\0\0", Pad=none, PADMODE=PAD_PKCS5)D =k.encrypt (data)Print "Encrypted:%r"%DPrint "decrypted:%r"%K.decrypt (d)assertK.decrypt (d, padmode=pad_pkcs5) = = Data
Python des and 3DES plus decryption