PK!]mmcred_encryption/__init__.py__version__ = '0.1.0' from cred_encryption.encryption import application def run(): application.run() PK!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 value encrypt {value : The value to encrypt} {--k|key : The key to encrypt against} """ def handle(self) -> None: value = self.argument('value') key = self.option('key') if key: SECRET_KEY = key else: 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 value decrypt {value : The value to decrypt} {--k|key : The key decrypt against} """ def handle(self) -> None: cipher_text = self.argument('cipher-text') key = self.option('key') if key: SECRET_KEY = key else: 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.1.dist-info/entry_points.txtN+I/N.,()JK.,(ϳM.JMGJPK!HڽTU%cred_encryption-0.1.1.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H!(cred_encryption-0.1.1.dist-info/METADATAAK@+DZ mQڃ`EQC2& lM,QSo˛74`W`}@G.*C]S?H zCr#c-x|+ޖԅ?84smOK[4ж/7P 9znJ})$^ Yg QCdρ}jǮ%E?+;َoޝt-y}Y'tJPxo`/PK!Hz1&cred_encryption-0.1.1.dist-info/RECORDͻr@>BbpQa!qqNsχℊ6XOp׾"[LZL/m K>MK3իp*^dx=N%% 4*wJ(:oQ\ӆ1&\IWUQZȷHDܖݭBd\J5̌u=Ȋ T~H:<P-X{j.=$eyw{ޛSpMm*F?or)fLzUh-S۷"A 4*C. ]OtC{7F6x