@@ -453,7 +453,7 @@ def __BitList_to_String(self, data):
453453
454454 def __permutate (self , table , block ):
455455 """Permutate this block with the specified table"""
456- return list ( map ( lambda x : block [x ], table ))
456+ return [ block [i ] for i in table ]
457457
458458 # Transform the secret key, so that it is ready for data processing
459459 # Create the 16 subkeys, K[1] - K[16]
@@ -506,7 +506,7 @@ def __des_crypt(self, block, crypt_type):
506506 self .R = self .__permutate (des .__expansion_table , self .R )
507507
508508 # 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 ])]
510510 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 :]]
511511 # Optimization: Replaced below commented code with above
512512 #j = 0
@@ -542,7 +542,7 @@ def __des_crypt(self, block, crypt_type):
542542 self .R = self .__permutate (des .__p , Bn )
543543
544544 # 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 )]
546546 # Optimization: This now replaces the below commented code
547547 #j = 0
548548 #while j < len(self.R):
@@ -603,7 +603,7 @@ def crypt(self, data, crypt_type):
603603 # Xor with IV if using CBC mode
604604 if self .getMode () == CBC :
605605 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 )]
607607 #j = 0
608608 #while j < len(block):
609609 # block[j] = block[j] ^ iv[j]
@@ -612,7 +612,7 @@ def crypt(self, data, crypt_type):
612612 processed_block = self .__des_crypt (block , crypt_type )
613613
614614 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 )]
616616 #j = 0
617617 #while j < len(processed_block):
618618 # processed_block[j] = processed_block[j] ^ iv[j]
0 commit comments