当前位置: 首页>>代码示例>>Python>>正文


Python CryptoEngine.get方法代码示例

本文整理汇总了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()
开发者ID:gadeleon,项目名称:pwman3,代码行数:27,代码来源:cli.py

示例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()
开发者ID:pwman3,项目名称:pwman3,代码行数:60,代码来源:cli.py

示例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()
开发者ID:gadeleon,项目名称:pwman3,代码行数:12,代码来源:crypto_tests.py

示例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
开发者ID:gadeleon,项目名称:pwman3,代码行数:14,代码来源:test_converter.py

示例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)
开发者ID:pwman3,项目名称:pwman3,代码行数:9,代码来源:database.py

示例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()
开发者ID:gadeleon,项目名称:pwman3,代码行数:9,代码来源:baseui.py

示例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())
开发者ID:pwman3,项目名称:pwman3,代码行数:9,代码来源:test_crypto_engine.py

示例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())
开发者ID:gadeleon,项目名称:pwman3,代码行数:9,代码来源:test_crypto_engine.py

示例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])
开发者ID:pwman3,项目名称:pwman3,代码行数:9,代码来源:test_importer.py

示例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)]
开发者ID:gadeleon,项目名称:pwman3,代码行数:9,代码来源:nodes.py

示例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())
开发者ID:pwman3,项目名称:pwman3,代码行数:9,代码来源:test_crypto_engine.py

示例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])
开发者ID:gadeleon,项目名称:pwman3,代码行数:9,代码来源:test_mongodb.py

示例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> "
开发者ID:pwman3,项目名称:pwman3,代码行数:29,代码来源:cli.py

示例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
开发者ID:gadeleon,项目名称:pwman3,代码行数:10,代码来源:baseui.py

示例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")
开发者ID:pwman3,项目名称:pwman3,代码行数:11,代码来源:test_crypto_engine.py


注:本文中的pwman.util.crypto_engine.CryptoEngine.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。