def test_basic_functionality(self): crypter = Crypter(KEYSET_PATH) for key, expected in SETTING_NAME_TO_DECRYPTED_VALUE_MAP.items(): value = getattr(encrypted_settings, key) plaintext = crypter.decrypt(value) self.assertEqual(plaintext, expected)
class EncryptedConfig(object): """ """ def __init__(self, keyset_path, encrypted_settings_module): self._crypter = Crypter(keyset_path=keyset_path) self._encrypted_settings_module = encrypted_settings_module self._settings_module = __import__(encrypted_settings_module, fromlist=['.']) def __getattr__(self, key): ciphertext = getattr(self._settings_module, key, None) if ciphertext is None: raise KeyError(key) plaintext = self._crypter.decrypt(ciphertext) return plaintext
""" Method 1 - explicitly calling decrypt method with a ciphertext. """ from encrypted_settings.crypter import Crypter crypter = Crypter('/my/path/to/keyczar_keyset') FACEBOOK_API_KEY = crypter.decrypt('ciphertext')
def __init__(self, keyset_path, encrypted_settings_module): self._crypter = Crypter(keyset_path=keyset_path) self._encrypted_settings_module = encrypted_settings_module self._settings_module = __import__(encrypted_settings_module, fromlist=['.'])