DES encryption/decrytpion class Supports ECB (Electronic Code Book) and CBC (Cypher Block Chaining) modes. pyDes.des(key,[mode], [IV]) key -> Bytes containing the encryption key, must be exactly 8 bytes mode -> Optional argument for encryption type, can be either pyDes.ECB (Electronic Code
| 245 | # DES # |
| 246 | ############################################################################# |
| 247 | class des(_baseDes): |
| 248 | """DES encryption/decrytpion class |
| 249 | |
| 250 | Supports ECB (Electronic Code Book) and CBC (Cypher Block Chaining) modes. |
| 251 | |
| 252 | pyDes.des(key,[mode], [IV]) |
| 253 | |
| 254 | key -> Bytes containing the encryption key, must be exactly 8 bytes |
| 255 | mode -> Optional argument for encryption type, can be either pyDes.ECB |
| 256 | (Electronic Code Book), pyDes.CBC (Cypher Block Chaining) |
| 257 | IV -> Optional Initial Value bytes, must be supplied if using CBC mode. |
| 258 | Must be 8 bytes in length. |
| 259 | pad -> Optional argument, set the pad character (PAD_NORMAL) to use |
| 260 | during all encrypt/decrpt operations done with this instance. |
| 261 | padmode -> Optional argument, set the padding mode (PAD_NORMAL or |
| 262 | PAD_PKCS5) to use during all encrypt/decrpt operations done |
| 263 | with this instance. |
| 264 | """ |
| 265 | |
| 266 | |
| 267 | # Permutation and translation tables for DES |
| 268 | __pc1 = [56, 48, 40, 32, 24, 16, 8, |
| 269 | 0, 57, 49, 41, 33, 25, 17, |
| 270 | 9, 1, 58, 50, 42, 34, 26, |
| 271 | 18, 10, 2, 59, 51, 43, 35, |
| 272 | 62, 54, 46, 38, 30, 22, 14, |
| 273 | 6, 61, 53, 45, 37, 29, 21, |
| 274 | 13, 5, 60, 52, 44, 36, 28, |
| 275 | 20, 12, 4, 27, 19, 11, 3 |
| 276 | ] |
| 277 | |
| 278 | # number left rotations of pc1 |
| 279 | __left_rotations = [ |
| 280 | 1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1 |
| 281 | ] |
| 282 | |
| 283 | # permuted choice key (table 2) |
| 284 | __pc2 = [ |
| 285 | 13, 16, 10, 23, 0, 4, |
| 286 | 2, 27, 14, 5, 20, 9, |
| 287 | 22, 18, 11, 3, 25, 7, |
| 288 | 15, 6, 26, 19, 12, 1, |
| 289 | 40, 51, 30, 36, 46, 54, |
| 290 | 29, 39, 50, 44, 32, 47, |
| 291 | 43, 48, 38, 55, 33, 52, |
| 292 | 45, 41, 49, 35, 28, 31 |
| 293 | ] |
| 294 | |
| 295 | # initial permutation IP |
| 296 | __ip = [57, 49, 41, 33, 25, 17, 9, 1, |
| 297 | 59, 51, 43, 35, 27, 19, 11, 3, |
| 298 | 61, 53, 45, 37, 29, 21, 13, 5, |
| 299 | 63, 55, 47, 39, 31, 23, 15, 7, |
| 300 | 56, 48, 40, 32, 24, 16, 8, 0, |
| 301 | 58, 50, 42, 34, 26, 18, 10, 2, |
| 302 | 60, 52, 44, 36, 28, 20, 12, 4, |
| 303 | 62, 54, 46, 38, 30, 22, 14, 6 |
| 304 | ] |
no outgoing calls
no test coverage detected