Esempio n. 1
0
    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)
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
"""
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')
Esempio n. 5
0
 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=['.'])
Esempio n. 6
0
 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=['.'])