• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python crypto_engine.CryptoEngine类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pwman.util.crypto_engine.CryptoEngine的典型用法代码示例。如果您正苦于以下问题:Python CryptoEngine类的具体用法?Python CryptoEngine怎么用?Python CryptoEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CryptoEngine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: main

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,代码行数:25,代码来源:cli.py


示例2: main

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,代码行数:58,代码来源:cli.py


示例3: test_get

 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,代码行数:10,代码来源:crypto_tests.py


示例4: __init__

    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,代码行数:12,代码来源:test_converter.py


示例5: get_user_password

 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,代码行数:7,代码来源:database.py


示例6: do_forget

 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,代码行数:7,代码来源:baseui.py


示例7: test6_is_timedout

 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,代码行数:7,代码来源:test_crypto_engine.py


示例8: test5_e_authenticate

 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,代码行数:7,代码来源:test_crypto_engine.py


示例9: test_2_create_node

 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,代码行数:7,代码来源:test_importer.py


示例10: tags

 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,代码行数:7,代码来源:nodes.py


示例11: test5_e_authenticate

 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,代码行数:7,代码来源:test_crypto_engine.py


示例12: test_6_list_nodes

 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,代码行数:7,代码来源:test_mongodb.py


示例13: __init__

    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,代码行数:27,代码来源:cli.py


示例14: _get_node_ids

 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,代码行数:8,代码来源:baseui.py


示例15: test_g_encrypt_decrypt_wrong_pass

 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,代码行数:9,代码来源:test_crypto_engine.py


示例16: __init__

 def __init__(self, clear_text=True, **kwargs):
     if clear_text:
         enc = CryptoEngine.get()
         self._username = enc.encrypt(kwargs.get('username')).strip()
         self._password = enc.encrypt(kwargs.get('password')).strip()
         self._url = enc.encrypt(kwargs.get('url')).strip()
         self._notes = enc.encrypt(kwargs.get('notes')).strip()
         self._tags = [enc.encrypt(t).strip() for t in
                       kwargs.get('tags', '')]
开发者ID:gadeleon,项目名称:pwman3,代码行数:9,代码来源:nodes.py


示例17: do_tags

 def do_tags(self, args):
     """
     print all existing tags
     """
     ce = CryptoEngine.get()
     print("Tags:")
     tags = self._db.listtags()
     for t in tags:
         print(ce.decrypt(t).decode())
开发者ID:gadeleon,项目名称:pwman3,代码行数:9,代码来源:baseui.py


示例18: test4_d_get_crypto

 def test4_d_get_crypto(self):
     ce = CryptoEngine.get()
     ce.callback = DummyCallback()
     secret2 = ce.changepassword(reader=give_key)
     secret1 = ce.changepassword(reader=give_key)
     # althouth the same secret key is used,
     # the secret hash is not the same, because a
     # different random seed is used when calling
     # CryptoEngine._get_digest
     self.assertNotEqual(secret1, secret2)
开发者ID:pwman3,项目名称:pwman3,代码行数:10,代码来源:test_crypto_engine.py


示例19: run

    def run(self, callback=CLICallback):

        enc = CryptoEngine.get()
        enc.callback = callback()
        self._open_db()

        for row in self._read_file():
            node = self._create_node(row)
            self._insert_node(node)

        self._db.close()
开发者ID:pwman3,项目名称:pwman3,代码行数:11,代码来源:importer.py


示例20: test_4_test_tags

 def test_4_test_tags(self):
     node = Node(clear_text=True,
                 **{'username': u"alice", 'password': u"secret",
                    'url': u"wonderland.com",
                    'notes': u"a really great place",
                    'tags': [u'foo', u'bar']})
     ce = CryptoEngine.get()
     self.db._get_or_create_tag(node._tags[0])
     self.assertEqual(1, self.db._get_or_create_tag(node._tags[0]))
     rv = self.db._get_or_create_tag(ce.encrypt('baz'))
     self.db._con.commit()
     self.assertEqual(3, rv)
开发者ID:gadeleon,项目名称:pwman3,代码行数:12,代码来源:test_sqlite.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pwn.die函数代码示例发布时间:2022-05-25
下一篇:
Python crypto.CryptoEngine类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap