heat.common.crypt 模块

class heat.common.crypt.SymmetricCrypto(enctype='AES')[source]

基类: object

对称密钥加密对象。

此类创建一个对称密钥加密对象,可用于解密任意数据。

注意:这是 oslo-incubator 中解密算法的重新实现,为了向后兼容而提供。一旦我们有了数据库迁移脚本,可以使用新的加密方法进行重新加密,作为升级的一部分,就可以删除此功能。

参数:

enctype – 加密密码名称(默认:AES)

decrypt(key, msg, b64decode=True)[source]

解密提供的密文。

密文可以选择性地进行 base64 编码。

默认使用 AES-128-CBC 和 IV。

参数:
  • key – 加密密钥。

  • msg – 密文,第一个块是 IV

返回值:

解密后的明文消息,在删除填充后。

heat.common.crypt.cryptography_decrypt_v1(value, encryption_key=None)[source]
heat.common.crypt.decrypt(method, data, encryption_key=None)[source]
heat.common.crypt.decrypted_dict(data, encryption_key=None)[source]

返回解密的字典。假定输入值是加密的 json 字段。

heat.common.crypt.encrypt(value, encryption_key=None)[source]
heat.common.crypt.encrypted_dict(data, encryption_key=None)[source]

返回加密的字典。值在加密前转换为 json

heat.common.crypt.get_valid_encryption_key(encryption_key, fix_length=False)[source]
heat.common.crypt.heat_decrypt(value, encryption_key=None)[source]

解密使用旧版本 Heat 加密的数据。

注意:encrypt 函数返回解密数据所需的功能。数据库然后存储此功能。当数据随后被检索(可能由 Heat 的较新版本)时,解密功能仍然存在。因此,虽然似乎此功能未被引用,但它将从数据库中被引用。

heat.common.crypt.list_opts()[source]
heat.common.crypt.oslo_decrypt_v1(value, encryption_key=None)[source]