Ejemplo n.º 1
0
def encode_blob(plaintext):
    assert isinstance(plaintext, bytes), 'Plaintext should be bytes'
    compressed = zlib.compress(plaintext)
    encryption_oracle = get_encryption_oracle('BLOCK_ENCRYPTION_KEY')
    ciphertext, scheme = encryption_oracle.encrypt(compressed)
    header = _pack_header(scheme)
    return header + ciphertext
Ejemplo n.º 2
0
def encode_blob(plaintext):
    assert isinstance(plaintext, bytes), 'Plaintext should be bytes'
    compressed = zlib.compress(plaintext)
    encryption_oracle = get_encryption_oracle('BLOCK_ENCRYPTION_KEY')
    ciphertext, scheme = encryption_oracle.encrypt(compressed)
    header = _pack_header(scheme)
    return header + ciphertext
Ejemplo n.º 3
0
    def secret(self, plaintext):
        if isinstance(plaintext, unicode):
            plaintext = plaintext.encode("utf8")
        if not isinstance(plaintext, bytes):
            raise TypeError("Invalid secret")

        with get_encryption_oracle("SECRET_ENCRYPTION_KEY") as e_oracle:
            self._secret, self.encryption_scheme = e_oracle.encrypt(plaintext)
Ejemplo n.º 4
0
Archivo: secret.py Proyecto: wmv/inbox
    def secret(self, plaintext):
        """
        The secret must be a byte sequence.
        The type must be specified as 'password'/'token'.

        """
        if not isinstance(plaintext, bytes):
            raise TypeError('Invalid secret')

        with get_encryption_oracle('SECRET_ENCRYPTION_KEY') as e_oracle:
            self._secret, self.encryption_scheme = e_oracle.encrypt(plaintext)