@@ -400,8 +400,8 @@ class RC4CipherNuoDB(BaseCipher):
400
400
name = 'RC4-local'
401
401
keysize = int (160 / 8 )
402
402
403
- def __init__ (self , _ , key ):
404
- # type: (bool, bytes) -> None
403
+ def __init__ (self , _ , key , convert = True ):
404
+ # type: (bool, bytes, bool ) -> None
405
405
"""Create an RC4 cipher using the given key.
406
406
407
407
This uses a native Python implementation which is sloooooow.
@@ -410,6 +410,7 @@ def __init__(self, _, key):
410
410
411
411
:param encrypt: True if encrypting, False if decrypting
412
412
:param key: The cipher key.
413
+ :param convert: If True hash the key
413
414
"""
414
415
super (RC4CipherNuoDB , self ).__init__ ()
415
416
@@ -419,7 +420,10 @@ def __init__(self, _, key):
419
420
420
421
state = self .__state
421
422
422
- data = bytesToArray (self ._convert_key (key ))
423
+ if convert :
424
+ key = self ._convert_key (key )
425
+ data = bytesToArray (key )
426
+
423
427
sz = len (data )
424
428
j = 0
425
429
for i in range (256 ):
@@ -465,14 +469,17 @@ class RC4CipherCryptography(BaseCipher):
465
469
name = 'RC4'
466
470
keysize = int (160 / 8 )
467
471
468
- def __init__ (self , encrypt , key ):
469
- # type: (bool, bytes) -> None
472
+ def __init__ (self , encrypt , key , convert = True ):
473
+ # type: (bool, bytes, bool ) -> None
470
474
"""Create an RC4 cipher using the given key.
471
475
472
476
:param encrypt: True if encrypting, False if decrypting
473
477
:param key: The key to initialize from.
478
+ :param convert: If True hash the key
474
479
"""
475
- algo = ARC4 (self ._convert_key (key ))
480
+ if convert :
481
+ key = self ._convert_key (key )
482
+ algo = ARC4 (key )
476
483
477
484
# There's a bug in older versions of mypy where they don't infer the
478
485
# optionality of mode correctly.
0 commit comments