コード例 #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
コード例 #2
0
ファイル: blobstorage.py プロジェクト: DrMoriarty/sync-engine
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
コード例 #3
0
ファイル: secret.py プロジェクト: zkryakgul/sync-engine-1
    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)
コード例 #4
0
ファイル: secret.py プロジェクト: 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)