@@ -8,36 +8,36 @@ class Crypt(CryptAbstract):
88 encryption_algorithm = "SYMMETRIC_DEFAULT" # 'SYMMETRIC_DEFAULT' | 'RSAES_OAEP_SHA_1' | 'RSAES_OAEP_SHA_256'
99 key_id = ""
1010
11- def __init__ (self , * args , ** kwargs ):
11+ def __init__ (self , * args , ** kwargs ) -> None :
1212 self ._init_boto ()
1313 super ().__init__ (* args , ** kwargs )
1414
15- def encrypt (self , message ) : # pragma: no cover
15+ def encrypt (self , message : str ) -> str : # pragma: no cover
1616 ciphertext = self .client .encrypt (
1717 KeyId = self .config .key_id ,
1818 Plaintext = bytes (message , encoding = "UTF-8" ),
1919 )
2020 return str (base64 .b64encode (ciphertext ["CiphertextBlob" ]), encoding = "UTF-8" )
2121
22- def _init_boto (self ): # pragma: no cover
22+ def _init_boto (self ) -> None : # pragma: no cover
2323 check_package_exists ("boto3" )
2424 boto3 = import_package ("boto3" )
2525 boto3 .set_stream_logger (name = 'botocore' )
2626 self .client = boto3 .client ('kms' )
2727
28- def _aws_decrypt (self , blob_text ) : # pragma: no cover
28+ def _aws_decrypt (self , blob_text : bytes ) -> str : # pragma: no cover
2929 response = self .client .decrypt (
3030 CiphertextBlob = blob_text ,
3131 KeyId = self .config .key_id ,
3232 EncryptionAlgorithm = self .encryption_algorithm
3333 )
3434 return str (response ['Plaintext' ], encoding = "UTF-8" )
3535
36- def _parse_encrypted (self , encrypted ) :
36+ def _parse_encrypted (self , encrypted : str ) -> bytes :
3737 blob_text = base64 .b64decode (encrypted )
3838 return blob_text
3939
40- def decrypt (self , encrypted ) :
40+ def decrypt (self , encrypted : str ) -> str :
4141 blob_text = self ._parse_encrypted (encrypted )
4242 decrypted = self ._aws_decrypt (blob_text )
4343
0 commit comments