本文整理汇总了Python中zato.common.crypto.CryptoManager.priv_key_location方法的典型用法代码示例。如果您正苦于以下问题:Python CryptoManager.priv_key_location方法的具体用法?Python CryptoManager.priv_key_location怎么用?Python CryptoManager.priv_key_location使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zato.common.crypto.CryptoManager
的用法示例。
在下文中一共展示了CryptoManager.priv_key_location方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_enrypt
# 需要导入模块: from zato.common.crypto import CryptoManager [as 别名]
# 或者: from zato.common.crypto.CryptoManager import priv_key_location [as 别名]
def test_enrypt(self):
""" Encrypt a message using the public key.
"""
_plain_text = uuid4().hex
with NamedTemporaryFile(prefix='zato-test-') as tf_priv:
with NamedTemporaryFile(prefix='zato-test-') as tf_pub:
tf_priv.write(priv_key)
tf_priv.flush()
tf_pub.write(pub_key)
tf_pub.flush()
cm_priv = CryptoManager()
cm_priv.priv_key_location = tf_priv.name
cm_priv.load_keys()
cm_pub = CryptoManager()
cm_pub.pub_key_location = tf_pub.name
cm_pub.load_keys()
encrypted = cm_pub.encrypt(_plain_text)
decrypted = cm_priv.decrypt(encrypted)
eq_(_plain_text, decrypted)
示例2: xtest_decrypt_priv_key_in_file
# 需要导入模块: from zato.common.crypto import CryptoManager [as 别名]
# 或者: from zato.common.crypto.CryptoManager import priv_key_location [as 别名]
def xtest_decrypt_priv_key_in_file(self):
""" Decrypt a message using a private key from file.
"""
with NamedTemporaryFile(prefix='zato-test-') as tf:
tf.write(priv_key)
tf.flush()
cm = CryptoManager()
cm.priv_key_location = tf.name
cm.load_keys()
eq_(plain_text, cm.decrypt(secret))