@@ -8,36 +8,36 @@ class Crypt(CryptAbstract):
8
8
encryption_algorithm = "SYMMETRIC_DEFAULT" # 'SYMMETRIC_DEFAULT' | 'RSAES_OAEP_SHA_1' | 'RSAES_OAEP_SHA_256'
9
9
key_id = ""
10
10
11
- def __init__ (self , * args , ** kwargs ):
11
+ def __init__ (self , * args , ** kwargs ) -> None :
12
12
self ._init_boto ()
13
13
super ().__init__ (* args , ** kwargs )
14
14
15
- def encrypt (self , message ) : # pragma: no cover
15
+ def encrypt (self , message : str ) -> str : # pragma: no cover
16
16
ciphertext = self .client .encrypt (
17
17
KeyId = self .config .key_id ,
18
18
Plaintext = bytes (message , encoding = "UTF-8" ),
19
19
)
20
20
return str (base64 .b64encode (ciphertext ["CiphertextBlob" ]), encoding = "UTF-8" )
21
21
22
- def _init_boto (self ): # pragma: no cover
22
+ def _init_boto (self ) -> None : # pragma: no cover
23
23
check_package_exists ("boto3" )
24
24
boto3 = import_package ("boto3" )
25
25
boto3 .set_stream_logger (name = 'botocore' )
26
26
self .client = boto3 .client ('kms' )
27
27
28
- def _aws_decrypt (self , blob_text ) : # pragma: no cover
28
+ def _aws_decrypt (self , blob_text : bytes ) -> str : # pragma: no cover
29
29
response = self .client .decrypt (
30
30
CiphertextBlob = blob_text ,
31
31
KeyId = self .config .key_id ,
32
32
EncryptionAlgorithm = self .encryption_algorithm
33
33
)
34
34
return str (response ['Plaintext' ], encoding = "UTF-8" )
35
35
36
- def _parse_encrypted (self , encrypted ) :
36
+ def _parse_encrypted (self , encrypted : str ) -> bytes :
37
37
blob_text = base64 .b64decode (encrypted )
38
38
return blob_text
39
39
40
- def decrypt (self , encrypted ) :
40
+ def decrypt (self , encrypted : str ) -> str :
41
41
blob_text = self ._parse_encrypted (encrypted )
42
42
decrypted = self ._aws_decrypt (blob_text )
43
43
0 commit comments