Exemple #1
0
    def __init__(self, base, *args, **kw):
        """
        :param base: Storage to transform
        :param bool debug: Output debug log messages
        """
        self.base = base

        self.debug = kw.pop("debug", False)
        if self.debug:
            self._debug_download_size = 0
            self._debug_download_count = 0

        for name in self.copied_methods:
            v = getattr(base, name, None)
            if v is not None:
                setattr(self, name, v)

        zope.interface.directlyProvides(self, zope.interface.providedBy(base))

        base.registerDB(self)

        self._transform = lambda data: encrypt(compress(data), no_cipher_name=True)
        self._transform_named = lambda data: encrypt(compress(data), no_cipher_name=False)
        self._untransform = lambda data: decompress(decrypt(data))

        self._root_oid = None
    def __init__(self, base, *args, **kw):
        """
        :param base: Storage to transform
        :param bool debug: Output debug log messages
        """
        self.base = base

        self.debug = kw.pop("debug", False)
        if self.debug:
            self._debug_download_size = 0
            self._debug_download_count = 0

        for name in self.copied_methods:
            v = getattr(base, name, None)
            if v is not None:
                setattr(self, name, v)

        zope.interface.directlyProvides(self, zope.interface.providedBy(base))

        base.registerDB(self)

        self._transform = lambda data: encrypt(compress(data),
                                               no_cipher_name=True)
        self._transform_named = lambda data: encrypt(compress(data),
                                                     no_cipher_name=False)
        self._untransform = lambda data: decompress(decrypt(data))

        self._root_oid = None
Exemple #3
0
def test_utilities():
    AES256Encrypter.register_class(default=True)

    init_crypto(passphrase="Hello world")

    test_text = b"Test text " * 100

    encrypted_text = encrypt(test_text)
    assert encrypted_text.startswith(b".e")
    assert decrypt(encrypted_text) == test_text
Exemple #4
0
    def __init__(self, base, *args, **kw):
        """
        :param base: Storage to transform
        :param bool debug: Output debug log messages
        """
        self.base = base

        self.debug = kw.pop("debug", False)
        if self.debug:
            self._debug_download_size = 0
            self._debug_download_count = 0

        for name in self.copied_methods:
            v = getattr(base, name, None)
            if v is not None:
                setattr(self, name, v)

        zope.interface.directlyProvides(self, zope.interface.providedBy(base))

        base.registerDB(self)

        self._transform = lambda data: encrypt(compress(data),
                                               no_cipher_name=True)
        self._transform_named = lambda data: encrypt(compress(data),
                                                     no_cipher_name=False)
        self._untransform = lambda data: decompress(decrypt(data))

        self._root_oid = base.get_root_id()

        # configure default encrytion based on root encryption:
        data = base.loadBefore(self._root_oid, maxtid)[0]
        sig = get_encryption_signature(data)
        if sig:
            _gsm.registerUtility(
                _gsm.getUtility(
                    zerodb.transform.interfaces.IEncrypter,
                    sig.decode(),
                ))
Exemple #5
0
    def __init__(self, base, *args, **kw):
        """
        :param base: Storage to transform
        :param bool debug: Output debug log messages
        """
        self.base = base

        self.debug = kw.pop("debug", False)
        if self.debug:
            self._debug_download_size = 0
            self._debug_download_count = 0

        for name in self.copied_methods:
            v = getattr(base, name, None)
            if v is not None:
                setattr(self, name, v)

        zope.interface.directlyProvides(self, zope.interface.providedBy(base))

        base.registerDB(self)

        self._transform = lambda data: encrypt(compress(data), no_cipher_name=True)
        self._transform_named = lambda data: encrypt(compress(data), no_cipher_name=False)
        self._untransform = lambda data: decompress(decrypt(data))

        self._root_oid = base.get_root_id()

        # configure default encrytion based on root encryption:
        data = base.loadBefore(self._root_oid, maxtid)[0]
        sig = get_encryption_signature(data)
        if sig:
            _gsm.registerUtility(
                _gsm.getUtility(
                    zerodb.transform.interfaces.IEncrypter,
                    sig.decode(),
                    )
                )