pushbullet.py 文件源码

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

项目:Intruder-detector-with-Raspberry-Pi-and-Pushbullet 作者: DeligenceTechnologies 项目源码 文件源码
def _encrypt_data(self, data):
        assert self._encryption_key

        from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
        from cryptography.hazmat.backends import default_backend

        iv = os.urandom(12)
        encryptor = Cipher(
            algorithms.AES(self._encryption_key),
            modes.GCM(iv),
            backend=default_backend()
        ).encryptor()

        ciphertext = encryptor.update(json.dumps(data).encode("UTF-8")) + encryptor.finalize()
        ciphertext = b"1" + encryptor.tag + iv + ciphertext
        return standard_b64encode(ciphertext).decode("ASCII")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号