Island: Extract fernet_object to an object variable in KeyBasedEncryptor
This commit is contained in:
parent
373d34dce6
commit
637926ed09
|
@ -21,11 +21,10 @@ class KeyBasedEncryptor(IEncryptor):
|
||||||
|
|
||||||
def __init__(self, key: bytes):
|
def __init__(self, key: bytes):
|
||||||
self._key = key
|
self._key = key
|
||||||
|
self._fernet_object = Fernet(self._key)
|
||||||
|
|
||||||
def encrypt(self, plaintext: bytes) -> bytes:
|
def encrypt(self, plaintext: bytes) -> bytes:
|
||||||
fernet_object = Fernet(self._key)
|
return self._fernet_object.encrypt(plaintext.encode())
|
||||||
return fernet_object.encrypt(plaintext.encode())
|
|
||||||
|
|
||||||
def decrypt(self, ciphertext: bytes) -> bytes:
|
def decrypt(self, ciphertext: bytes) -> bytes:
|
||||||
fernet_object = Fernet(self._key)
|
return self._fernet_object.decrypt(ciphertext)
|
||||||
return fernet_object.decrypt(ciphertext)
|
|
||||||
|
|
Loading…
Reference in New Issue