本文整理汇总了Python中pwman.util.crypto_engine.CryptoEngine.get方法的典型用法代码示例。如果您正苦于以下问题:Python CryptoEngine.get方法的具体用法?Python CryptoEngine.get怎么用?Python CryptoEngine.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pwman.util.crypto_engine.CryptoEngine
的用法示例。
在下文中一共展示了CryptoEngine.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def main():
args = parser_options().parse_args()
PwmanCli, OSX = get_ui_platform(sys.platform)
xselpath, dbtype, config = get_conf_options(args, OSX)
dburi = config.get_value('Database', 'dburi')
print(dburi)
dbver = get_db_version(config, args)
CryptoEngine.get()
db = factory.createdb(dburi, dbver)
if args.import_file:
importer = Importer((args, config, db))
importer.run()
sys.exit(0)
cli = PwmanCli(db, xselpath, CLICallback, config)
try:
cli.cmdloop()
except KeyboardInterrupt as e:
print(e)
finally:
config.save()
示例2: main
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def main():
args = parser_options().parse_args()
PwmanCli, OSX = get_ui_platform(sys.platform)
xselpath, dbtype, config = get_conf_options(args, OSX)
dburi = config.get_value('Database', 'dburi')
client_info = config.get_value('Updater', 'client_info')
if not client_info:
client_info = calculate_client_info()
config.set_value('Updater', 'client_info', client_info)
if not has_cryptography:
import colorama
if config.get_value('Crypto', 'supress_warning').lower() != 'yes':
print("{}WARNING: You are not using PyCrypto!!!\n"
"WARNING: You should install PyCrypto for better security and " # noqa
"perfomance\nWARNING: You can supress this warning by editing " # noqa
"pwman config file.{}".format(colorama.Fore.RED,
colorama.Style.RESET_ALL))
if args.cmd == "version":
latest = check_version(version, client_info)
print("version: %s is latest: %s" % (version, latest))
sys.exit(0)
elif config.get_value('Updater',
'supress_version_check').lower() != 'yes':
check_version(version, client_info)
print(dburi)
dbver = get_db_version(config, args)
timeout = int(config.get_value('Global', 'lock_timeout'))
CryptoEngine.get(timeout)
db = factory.createdb(dburi, dbver)
if args.file_delim:
importer = Importer((args, config, db))
importer.run()
sys.exit(0)
cli = PwmanCli(db, xselpath, CLICallback, config)
if args.cmd == "p":
cli.onecmd("pp %s" % args.node)
sys.exit(0)
if args.cmd == "cp":
cli.onecmd("cp %s" % args.node)
sys.exit(0)
try:
cli.cmdloop()
except KeyboardInterrupt as e:
print(e)
finally:
config.save()
示例3: test_get
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def test_get(self):
CryptoEngine._instance_new = None
old_engine = CryptoEngine.get(0.4)
self.assertIsInstance(old_engine, CryptoEngineOld)
CryptoEngine._instance = None
new_engine = CryptoEngine.get(dbver=0.5)
self.assertIsInstance(new_engine, CryptoEngine)
self.assertFalse(isinstance(new_engine, CryptoEngineOld))
CryptoEngine._instance = None
old_engine = CryptoEngine.get()
示例4: __init__
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def __init__(self):
config.set_defaults(default_config)
enc = CryptoEngine.get(dbver=0.4)
enc.callback = DummyCallback4()
self.enc1 = copy.copy(enc)
enc = CryptoEngine.get(dbver=0.5)
enc.callback = DummyCallback4()
self.enc2 = copy.copy(enc)
self.db1 = SQLiteDatabaseNewForm('konverter-v0.4.db', dbformat=0.4)
self.db2 = SQLiteDatabaseNewForm('konverter-v0.5.db', dbformat=0.5)
assert self.enc1 is not self.enc2
示例5: get_user_password
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def get_user_password(self):
"""
get the databases password from the user
"""
enc = CryptoEngine.get()
newkey = enc.changepassword()
return self.savekey(newkey)
示例6: do_forget
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def do_forget(self, args):
"""
drop saved key forcing the user to re-enter the master
password
"""
enc = CryptoEngine.get()
enc.forget()
示例7: test6_is_timedout
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def test6_is_timedout(self):
ce = CryptoEngine.get()
ce._expires_at = time.time() - 2
time.sleep(1.1)
self.assertTrue(ce._is_timedout())
self.assertIsNone(ce._cipher)
self.assertFalse(ce._is_authenticated())
示例8: test5_e_authenticate
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def test5_e_authenticate(self):
ce = CryptoEngine.get()
ce._reader = give_key
self.assertFalse(ce.authenticate('verywrong'))
self.assertTrue(ce.authenticate('12345'))
ce._timeout = -1
self.assertTrue(ce._is_authenticated())
示例9: test_2_create_node
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def test_2_create_node(self):
# create a node , should be encrypted, but not yet inserted to db
n = "alice;wonderland.com;secert;scratch;foo,bar".split(";")
node = self.importer._create_node(n)
ce = CryptoEngine.get()
self.assertEqual(ce.decrypt(node._username).decode(), u'alice')
self.assertEqual([b'foo', b'bar'], [t for t in node.tags])
示例10: tags
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def tags(self):
enc = CryptoEngine.get()
try:
return [enc.decrypt(tag).decode() for tag in
filter(None, self._tags)]
except Exception:
return [tag for tag in filter(None, self._tags)]
示例11: test5_e_authenticate
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def test5_e_authenticate(self):
ce = CryptoEngine.get()
ce._reader = give_key
self.assertFalse(ce.authenticate(b'verywrong'))
self.assertTrue(ce.authenticate(b'12345'))
ce._expires_at = int(time.time()) + 600
self.assertTrue(ce._is_authenticated())
示例12: test_6_list_nodes
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def test_6_list_nodes(self):
ret = self.db.listnodes()
self.assertEqual(ret, [1])
ce = CryptoEngine.get()
fltr = ce.encrypt("footag")
ret = self.db.listnodes(fltr)
self.assertEqual(ret, [1])
示例13: __init__
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def __init__(self, db, hasxsel, callback, config_parser, **kwargs):
"""
initialize CLI interface, set up the DB
connecion, see if we have xsel ...
"""
super(PwmanCli, self).__init__(**kwargs)
self.intro = "%s %s (c) visit: %s" % ('pwman3', version, website)
self._historyfile = config_parser.get_value("Readline", "history")
self.hasxsel = hasxsel
self.config = config_parser
try:
enc = CryptoEngine.get()
enc.callback = callback()
self._db = db
# this cascades down all the way to setting the database key
self._db.open()
except Exception as e: # pragma: no cover
self.error(e)
sys.exit(1)
try:
readline.read_history_file(self._historyfile)
except IOError as e: # pragma: no cover
pass
self.prompt = "pwman> "
示例14: _get_node_ids
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def _get_node_ids(self, args):
filter = None
if args:
filter = args.split()[0]
ce = CryptoEngine.get()
filter = ce.encrypt(filter)
nodeids = self._db.listnodes(filter=filter)
return nodeids
示例15: test_g_encrypt_decrypt_wrong_pass
# 需要导入模块: from pwman.util.crypto_engine import CryptoEngine [as 别名]
# 或者: from pwman.util.crypto_engine.CryptoEngine import get [as 别名]
def test_g_encrypt_decrypt_wrong_pass(self):
ce = CryptoEngine.get()
ce._cipher = None
ce._getsecret = give_wrong_key
self.assertRaises(CryptoException, ce.encrypt, b"secret")
ce._getsecret = lambda x: b'12345'
secret = ce.encrypt(b"topsecret")
decrypt = ce.decrypt(secret)
self.assertEqual(decrypt.decode(), "topsecret")