本文整理汇总了Python中passpie.crypt.Cryptor.create_keys方法的典型用法代码示例。如果您正苦于以下问题:Python Cryptor.create_keys方法的具体用法?Python Cryptor.create_keys怎么用?Python Cryptor.create_keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类passpie.crypt.Cryptor
的用法示例。
在下文中一共展示了Cryptor.create_keys方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_keys_raises_file_exist_error_when_keys_found_in_path
# 需要导入模块: from passpie.crypt import Cryptor [as 别名]
# 或者: from passpie.crypt.Cryptor import create_keys [as 别名]
def test_create_keys_raises_file_exist_error_when_keys_found_in_path(self):
cryptor = Cryptor("path/to/database")
self.patch("passpie.crypt.os.path.exists",
self.Mock(return_value=True))
with self.assertRaises(FileExistsError):
cryptor.create_keys("passphrase")
示例2: test_create_keys_export_public_and_secret_keys_into_keyspath
# 需要导入模块: from passpie.crypt import Cryptor [as 别名]
# 或者: from passpie.crypt.Cryptor import create_keys [as 别名]
def test_create_keys_export_public_and_secret_keys_into_keyspath(self):
cryptor = Cryptor("path/to/database")
passphrase = "passphrase"
self.patch("passpie.crypt.os.path.exists",
self.Mock(return_value=False))
keys = self.Mock(fingerprint="HEX")
cryptor._gpg.gen_key.return_value = keys
mock_open = self.patch("passpie.crypt.mkdir_open",
self.mock_open(), create=True)
mock_keyfile = self.Mock()
mock_open().__enter__.return_value = mock_keyfile
cryptor.create_keys(passphrase)
key_input = KEY_INPUT.format(passphrase)
cryptor._gpg.gen_key.assert_called_once_with(key_input)
cryptor._gpg.export_keys.assert_any_call(keys.fingerprint)
pubkey = cryptor._gpg.export_keys(keys.fingerprint)
seckey = cryptor._gpg.export_keys(keys.fingerprint, secret=True)
cryptor._gpg.export_keys.assert_any_call(keys.fingerprint, secret=True)
mock_keyfile.write.called_once_with(pubkey + seckey)