PK!]mmcred_encryption/__init__.py__version__ = '0.1.0' from cred_encryption.encryption import application def run(): application.run() PK!Y T~cred_encryption/encryption.pyimport os import base64 from cryptography.fernet import Fernet from cleo import Application, Command as BaseCommand from typing import Optional class Command(BaseCommand): @property def secret_key(self) -> Optional[str]: try: return os.environ['OLAS_SECURITYCONFIG_HASH'][:32] except KeyError: self.line('Unable to perform encrypt/decrypt operations because the environmental variable ' '`OLAS_SECURITYCONFIG_HASH` is not set') return None class EncryptCommand(Command): """ Encrypts a given key encrypt {value : The value to encrypt} """ def handle(self) -> None: value = self.argument('value') SECRET_KEY = self.secret_key if SECRET_KEY: key = base64.urlsafe_b64encode(bytes(SECRET_KEY.encode())) cipher_suite = Fernet(key) plain_text = cipher_suite.encrypt(value.encode()) self.line('ENCRYPTED VALUE:') self.line(f'{plain_text.decode()}') class DecryptCommand(Command): """ Decrypts a given key decrypt {cipher-text : The value to decrypt} """ def handle(self) -> None: cipher_text = self.argument('cipher-text') SECRET_KEY = self.secret_key if SECRET_KEY: key = base64.urlsafe_b64encode(bytes(SECRET_KEY.encode())) cipher_suite = Fernet(key) plain_text = cipher_suite.decrypt(cipher_text.encode()) self.line('DECRYPTED VALUE:') self.line(f'{plain_text.decode()}') application = Application() application.add(DecryptCommand()) application.add(EncryptCommand()) application.run() PK!Hv+20cred_encryption-0.1.0.dist-info/entry_points.txtN+I/N.,()JK.,(ϳM.JMGJPK!HڽTU%cred_encryption-0.1.0.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!Hk}(cred_encryption-0.1.0.dist-info/METADATAAK09*4C+(.zڱ 4MMZ{'{sO68z! JThFPex% +iRHq,[n;;Y}MKuo^ ۡ |7 1YR(ll^|`Tһk/ EG@f?PK!]mmcred_encryption/__init__.pyPK!Y T~cred_encryption/encryption.pyPK!Hv+20cred_encryption-0.1.0.dist-info/entry_points.txtPK!HڽTU%Ecred_encryption-0.1.0.dist-info/WHEELPK!Hk}(cred_encryption-0.1.0.dist-info/METADATAPK!Ht)(2& cred_encryption-0.1.0.dist-info/RECORDPK