client.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:nucypher-kms 作者: nucypher 项目源码 文件源码
def encrypt(self, data, key, path=None, algorithm=None):
        """
        Encrypts data in a form ready to ship to the storage layer.

        :param bytes data: Data to encrypt
        :param bytes key: Data encryption key to use when encrypting
        :param tuple(str) path: Path to the data (to be able to share
            sub-paths). If None, encrypted with just our pubkey.
            If contains only 1 element or is a string, this is just used as a
            unique identifier w/o granular encryption.
        :param dict algorithm: Algorithm parameters (name, curve, re-encryption
            type, m/n etc). None if default

        :return: Encrypted data
        :rtype: bytes
        """
        ciphertext = msgpack.dumps(self.keyring.encrypt(data, data_key))

        # Derive keys and encrypt them
        # TODO: https://github.com/nucypher/nucypher-kms/issues/33
        if path is not None:
            enc_keys = self.encrypt_key(data_key, path=path)
        else:
            enc_keys = [self.encrypt_key(data_key, path=path)]
        return storage_data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号