@@ -453,7 +453,7 @@ def __BitList_to_String(self, data):
453
453
454
454
def __permutate (self , table , block ):
455
455
"""Permutate this block with the specified table"""
456
- return list ( map ( lambda x : block [x ], table ))
456
+ return [ block [i ] for i in table ]
457
457
458
458
# Transform the secret key, so that it is ready for data processing
459
459
# Create the 16 subkeys, K[1] - K[16]
@@ -506,7 +506,7 @@ def __des_crypt(self, block, crypt_type):
506
506
self .R = self .__permutate (des .__expansion_table , self .R )
507
507
508
508
# Exclusive or R[i - 1] with K[i], create B[1] to B[8] whilst here
509
- self .R = list ( map ( lambda x , y : x ^ y , self .R , self .Kn [iteration ]))
509
+ self .R = [ b ^ k for b , k in zip ( self .R , self .Kn [iteration ])]
510
510
B = [self .R [:6 ], self .R [6 :12 ], self .R [12 :18 ], self .R [18 :24 ], self .R [24 :30 ], self .R [30 :36 ], self .R [36 :42 ], self .R [42 :]]
511
511
# Optimization: Replaced below commented code with above
512
512
#j = 0
@@ -542,7 +542,7 @@ def __des_crypt(self, block, crypt_type):
542
542
self .R = self .__permutate (des .__p , Bn )
543
543
544
544
# Xor with L[i - 1]
545
- self .R = list ( map ( lambda x , y : x ^ y , self .R , self .L ))
545
+ self .R = [ b ^ l for b , l in zip ( self .R , self .L )]
546
546
# Optimization: This now replaces the below commented code
547
547
#j = 0
548
548
#while j < len(self.R):
@@ -603,7 +603,7 @@ def crypt(self, data, crypt_type):
603
603
# Xor with IV if using CBC mode
604
604
if self .getMode () == CBC :
605
605
if crypt_type == des .ENCRYPT :
606
- block = list ( map ( lambda x , y : x ^ y , block , iv ))
606
+ block = [ b ^ v for b , v in zip ( block , iv )]
607
607
#j = 0
608
608
#while j < len(block):
609
609
# block[j] = block[j] ^ iv[j]
@@ -612,7 +612,7 @@ def crypt(self, data, crypt_type):
612
612
processed_block = self .__des_crypt (block , crypt_type )
613
613
614
614
if crypt_type == des .DECRYPT :
615
- processed_block = list ( map ( lambda x , y : x ^ y , processed_block , iv ))
615
+ processed_block = [ b ^ v for b , v in zip ( processed_block , iv )]
616
616
#j = 0
617
617
#while j < len(processed_block):
618
618
# processed_block[j] = processed_block[j] ^ iv[j]
0 commit comments