PK!]mmcred_encryption/__init__.py__version__ = '0.1.0' from cred_encryption.encryption import application def run(): application.run() PK!e22cred_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 and the `key` argument was not provided') return None class EncryptCommand(Command): """ Encrypts a given value encrypt {value : The value to encrypt} {key? : The key to encrypt against} """ def handle(self) -> None: value = self.argument('value') key = self.argument('key') if key: SECRET_KEY = key[:32] 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 encrypt} {key? : The key to encrypt against} """ def handle(self) -> None: cipher_text = self.argument('value') key = self.argument('key') if key: SECRET_KEY = key[:32] 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.3.0.dist-info/entry_points.txtN+I/N.,()JK.,(ϳM.JMGJPK!HڽTU%cred_encryption-0.3.0.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H\(cred_encryption-0.3.0.dist-info/METADATAAK@+b"(AbQC2& lM,QSo˛74`W`}Tr]2U~A Q9);2=y)BlI]#܍C9כm[ECm+h}C P:ڊN=hO0UZmZ [={5szx:d\g;yM:z2H.A"ƂYPK!HA1&cred_encryption-0.3.0.dist-info/RECORDͻv0g4@0tJ(G%rhoO{\>KIƒ~j9m3!QNNPIJ|]ScZț>,t.Ӓf >lB+VSv9L4H ]W@L(˛ '6A#Vcq*{IV`5c[oxbݎ *x9Yk_pwuѪ ۤQ]g>vX ޚ ߸qHuj5{m\_)M^zI顿7WxaPK!]mmcred_encryption/__init__.pyPK!e22cred_encryption/encryption.pyPK!Hv+20 cred_encryption-0.3.0.dist-info/entry_points.txtPK!HڽTU% cred_encryption-0.3.0.dist-info/WHEELPK!H\(# cred_encryption-0.3.0.dist-info/METADATAPK!HA1&\ cred_encryption-0.3.0.dist-info/RECORDPK