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

Python simplecrypt.decrypt函数代码示例

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

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



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

示例1: test_bytes_password

 def test_bytes_password(self):
     ptext = decrypt(b'password', encrypt(b'password', b'message'))
     assert ptext == b'message', ptext
     ptext = decrypt('password', encrypt(b'password', b'message'))
     assert ptext == b'message', ptext
     ptext = decrypt(b'password', encrypt('password', b'message'))
     assert ptext == b'message', ptext
开发者ID:italianpride15,项目名称:blueconnect-gae,代码行数:7,代码来源:tests.py


示例2: test_unicode_ciphertext

 def test_unicode_ciphertext(self):
     u_ciphertext = b'some string'.decode('utf8')
     try:
         decrypt('password', u_ciphertext)
         assert False, 'expected error'
     except DecryptionException as e:
         assert 'bytes' in str(e), e
开发者ID:italianpride15,项目名称:blueconnect-gae,代码行数:7,代码来源:tests.py


示例3: test_bad_password

 def test_bad_password(self):
     ctext = bytearray(encrypt('password', 'message'))
     try:
         decrypt('badpassword', ctext)
         assert False, 'expected error'
     except DecryptionException as e:
         assert 'Bad password' in str(e), e
开发者ID:italianpride15,项目名称:blueconnect-gae,代码行数:7,代码来源:tests.py


示例4: get_profile

 def get_profile(self, profile, pwd):
     self.c.execute("SELECT * FROM profiles WHERE profile=?", (profile,))
     res = self.c.fetchone()
     uname = simplecrypt.decrypt(pwd, res[1]).decode('utf-8')
     api_key = simplecrypt.decrypt(pwd, res[2]).decode('utf-8')
     token = simplecrypt.decrypt(pwd, res[3]).decode('utf-8')
     return (uname, pwd, api_key, token)
开发者ID:frame11,项目名称:VAPy,代码行数:7,代码来源:Profiles.py


示例5: test_modification

 def test_modification(self):
     ctext = bytearray(encrypt('password', 'message'))
     ctext[10] = ctext[10] ^ 85
     try:
         decrypt('password', ctext)
         assert False, 'expected error'
     except DecryptionException as e:
         assert 'modified' in str(e), e
开发者ID:italianpride15,项目名称:blueconnect-gae,代码行数:8,代码来源:tests.py


示例6: test_length

 def test_length(self):
     ctext = encrypt('password', '')
     assert not decrypt('password', ctext)
     try:
         decrypt('password', bytes(bytearray(ctext)[:-1]))
         assert False, 'expected error'
     except DecryptionException as e:
         assert 'Missing' in str(e), e
开发者ID:italianpride15,项目名称:blueconnect-gae,代码行数:8,代码来源:tests.py


示例7: test_unicode_plaintext

 def test_unicode_plaintext(self):
     ptext = decrypt(u'password', encrypt(u'password', u'message'))
     assert ptext.decode('utf8') == 'message', ptext
     ptext = decrypt(u'password', encrypt(u'password', u'message'.encode('utf8')))
     assert ptext == 'message'.encode('utf8'), ptext
     ptext = decrypt(u'password', encrypt(u'password', u'¥£€$¢₡₢₣₤₥₦₧₨₩₪₫₭₮₯₹'))
     assert ptext.decode('utf8') == u'¥£€$¢₡₢₣₤₥₦₧₨₩₪₫₭₮₯₹', ptext
     ptext = decrypt(u'password', encrypt(u'password', u'¥£€$¢₡₢₣₤₥₦₧₨₩₪₫₭₮₯₹'.encode('utf8')))
     assert ptext == u'¥£€$¢₡₢₣₤₥₦₧₨₩₪₫₭₮₯₹'.encode('utf8'), ptext
开发者ID:d10n,项目名称:simple-crypt,代码行数:9,代码来源:tests.py


示例8: load_db

def load_db(password=''):
  creds = {}
  keychain = Keychain()
  account = getlogin()
  payload = keychain.get_generic_password(KEYCHAIN, account, SERVICE_NAME)
  if payload and 'password' in payload:
    parts = payload['password'].split(JOIN_STRING)
    if(len(parts) > 1):
      creds['password'] = password and decrypt(password, unhexlify(parts[1])) or parts[1]
      creds['username'] = password and decrypt(password, unhexlify(parts[0])) or parts[0]
  return creds
开发者ID:schwark,项目名称:alfred-alarmcom,代码行数:11,代码来源:list_collector.py


示例9: get_config

def get_config():
    secret = os.getenv('SECRET_KEY', 'my_secret_key')
    current_path = os.path.dirname(os.path.realpath(__file__))
    config = ConfigParser()
    config.read(os.path.join(current_path, 'taskstore.ini'))
    host = base64.b64decode(config.get('db_connection', 'host'))
    user = base64.b64decode(config.get('db_connection', 'user'))
    password = base64.b64decode(config.get('db_connection', 'password'))
    db = base64.b64decode(config.get('db_connection', 'db'))
    return (decrypt(secret, host),
        decrypt(secret, user),
        decrypt(secret, password),
        decrypt(secret, db))
开发者ID:ivandavid77,项目名称:wa_worker,代码行数:13,代码来源:taskstore.py


示例10: get_config

def get_config():
    secret = os.getenv('SECRET_KEY', 'my_secret_key')
    current_path = os.path.dirname(os.path.realpath(__file__))
    config = ConfigParser()
    config.read(os.path.join(current_path, 'mail.ini'))
    host = base64.b64decode(config.get('smtp', 'host'))
    user = base64.b64decode(config.get('smtp', 'user'))
    password = base64.b64decode(config.get('smtp', 'password'))
    admin = base64.b64decode(config.get('smtp', 'admin'))
    return (decrypt(secret, host),
        decrypt(secret, user),
        decrypt(secret, password),
        decrypt(secret, admin))
开发者ID:ivandavid77,项目名称:wa_worker,代码行数:13,代码来源:mail.py


示例11: decrypt_disclaimers

def decrypt_disclaimers(input, output, fieldsep, rowsep):
    if PASSWORD is None:
        print('You need to set the SIMPLECRYPT_PASSWORD')
        return

    if output is None:
        # timestamp the filename with the datetime it was downloaded
        timestamp = time.strftime(
            '%Y%m%d%H%M', time.gmtime(os.path.getctime(input.name))
        )
        output = 'disclaimers_backup_{}.csv'.format(timestamp)

    encrypted_text = input.read()
    decrypted_text = decrypt(PASSWORD, encrypted_text)
    decrypted_text = str(decrypted_text).lstrip("b'").rstrip("'")
    decrypted_data = decrypted_text.split(fieldsep)

    with open(output, 'wt') as out:
        wr = csv.writer(out)

        for entry in decrypted_data:
            data = entry.split(rowsep)
            wr.writerow([smart_str(datum) for datum in data])

    os.unlink(input.name)

    print(
        '{} records decrypted and written to {}'.format(
            len(decrypted_data) - 1, output
        )
    )
开发者ID:rebkwok,项目名称:decrypt,代码行数:31,代码来源:decrypt_disclaimers.py


示例12: item

def item(id):
    myitem = PasswordRecords.query.get_or_404(id)
    site = myitem.displayname
    username = myitem.username
    password = decrypt(globalkey, myitem.password)
    detail = myitem.detail
    return render_template('item.html',name=site,name2="http://" + site,username=username,password=password,detail=detail)
开发者ID:zhiweicai,项目名称:passwordmind,代码行数:7,代码来源:password.py


示例13: read_config

def read_config(file_path):
    """
    Tries to read config from 2 types of files.
    If json file is available it will use that one.
    If there is no json file it will use the encrypted file.
    """
    if file_path.endswith(".json"):
        if os.path.isfile(file_path):
            print(green("Load config %s" % (file_path)))
            with open(file_path) as json_config:
                try:
                    return json.load(json_config)
                except Exception, e:
                    abort(red("Cannot read config, is the config correct?. `%s`" % e))
                
        encrypt_file_path = "%s.encrypt" % file_path
        
        if not os.path.isfile(encrypt_file_path):
            abort(red("No config `%s` found." % encrypt_file_path))
        
        with open(encrypt_file_path) as ciphertext:
            password = utils.get_master_password()
            
            try:
                config = decrypt(env.master_password, ciphertext.read()).decode('UTF-8')
            except DecryptionException, e:
                abort(red(e))
            try:
                return json.loads(config)
            except Exception, e:
                abort(red("Cannot read config, is the config correct? `%s`" % e))
开发者ID:Jasperkroon,项目名称:deploy-commander,代码行数:31,代码来源:config.py


示例14: do_revoke

    def do_revoke(self):
        try:
            authid = self.request.get('authid')
            if authid is None or authid == '':
                return "Error: No authid in query"

            if authid.find(':') <= 0:
                return 'Error: Invalid authid in query'

            keyid = authid[:authid.index(':')]
            password = authid[authid.index(':') + 1:]

            if keyid == 'v2':
                return 'Error: The token must be revoked from the service provider. You can de-authorize the application on the storage providers website.'

            entry = dbmodel.AuthToken.get_by_key_name(keyid)
            if entry is None:
                return 'Error: No such user'

            data = base64.b64decode(entry.blob)
            resp = None

            try:
                resp = json.loads(simplecrypt.decrypt(password, data).decode('utf8'))
            except:
                logging.exception('decrypt error')
                return 'Error: Invalid authid password'

            entry.delete()
            return "Token revoked"

        except:
            logging.exception('handler error')
            return 'Error: Server error'
开发者ID:duplicati,项目名称:oauth-handler,代码行数:34,代码来源:main.py


示例15: _create_client

    def _create_client(self, data):
        """ Creates client from data

            implements some password obfuscation

            :param dict data: dictionary with client params
            :return: Client instance
            :rtype: openerp_proxy.client
        """
        if 'pwd' not in data:
            data = data.copy()
            if self.session.option('store_passwords') and 'password' in data:
                import base64
                encoded_pwd = data.pop('password').encode('utf8')
                crypter, password = base64.b64decode(encoded_pwd).split(b':')
                if crypter == b'simplecrypt':  # pragma: no cover
                    # Legacy support
                    import simplecrypt
                    data['pwd'] = simplecrypt.decrypt(
                        Client.to_url(data), base64.b64decode(password))
                elif crypter == b'plain':
                    # Current crypter
                    data['pwd'] = password.decode('utf-8')
                else:  # pragma: no cover
                    raise Exception("Unknown crypter (%s) used in session"
                                    "" % repr(crypter))
            else:
                # TODO: check if in interactive mode
                data['pwd'] = getpass('Password: ')  # pragma: no cover

        return super(SessionClientManager, self)._create_client(data)
开发者ID:katyukha,项目名称:openerp-proxy,代码行数:31,代码来源:session.py


示例16: decode

    def decode(cipher):
        "Decodes the validation key."
        # Decryption
        c_text = base64.b64decode(bytes(cipher, 'utf-8'))
        json_str = decrypt(encryption_keys['game_key'], c_text).decode()

        return json.loads(json_str)
开发者ID:SudhanvaMG,项目名称:survaider-app,代码行数:7,代码来源:model.py


示例17: _validate_user_and_passwd

 def _validate_user_and_passwd():
     u = Config.get_config().user
     p = Config.get_config().passwd
     if user != u:
         raise InvalidUserError(user)
     elif passwd != decrypt('devops', p):
         raise InvalidPasswdError(passwd)
开发者ID:lafengnan,项目名称:maintenance,代码行数:7,代码来源:utils.py


示例18: do_revoke

    def do_revoke(self):
        try:
            authid = self.request.get('authid')
            if authid == None or authid == '':
                return "Error: No authid in query"

            if authid.find(':') <= 0:
                return 'Error: Invalid authid in query'

            keyid = authid[:authid.index(':')]
            password = authid[authid.index(':')+1:]

            entry = dbmodel.AuthToken.get_by_key_name(keyid)
            if entry == None:
                return 'Error: No such user'

            data = base64.b64decode(entry.blob)
            resp = None

            try:
                resp = json.loads(simplecrypt.decrypt(password, data).decode('utf8'))
            except:
                logging.exception('decrypt error')
                return 'Error: Invalid authid password'

            entry.delete()
            return "Token revoked"

        except:
            logging.exception('handler error')
            return 'Error: Server error'
开发者ID:thekrugers,项目名称:oauth-handler,代码行数:31,代码来源:main.py


示例19: test_unicode_plaintext

 def test_unicode_plaintext(self):
     def u(string):
         u_type = type(b''.decode('utf8'))
         if not isinstance(string, u_type):
             return string.decode('utf8')
         return string
     u_message = u('message')
     u_high_order = u('¥£€$¢₡₢₣₤₥₦₧₨₩₪₫₭₮₯₹')
     ptext = decrypt('password', encrypt('password', u_message))
     assert ptext.decode('utf8') == 'message', ptext
     ptext = decrypt('password', encrypt('password', u_message.encode('utf8')))
     assert ptext == 'message'.encode('utf8'), ptext
     ptext = decrypt('password', encrypt('password', u_high_order))
     assert ptext.decode('utf8') == u_high_order, ptext
     ptext = decrypt('password', encrypt('password', u_high_order.encode('utf8')))
     assert ptext == u_high_order.encode('utf8'), ptext
开发者ID:italianpride15,项目名称:blueconnect-gae,代码行数:16,代码来源:tests.py


示例20: get_credentials

def get_credentials():
    '''
    Get a SafeConfigParser instance with FACT credentials
    On the first call, you will be prompted for the FACT password

    The folling credentials are stored:
    - telegram
        - token

    - database
        - user
        - password
        - host
        - database

    - twilio
        - sid
        - auth_token
        - number

    use get_credentials().get(group, element) to retrieve elements
    '''
    with resource_stream('fact_credentials', 'credentials.encrypted') as f:
        print('Please enter the current, universal FACT password')
        passwd = getpass()
        decrypted = decrypt(passwd, f.read()).decode('utf-8')

    config = SafeConfigParser()
    config.readfp(StringIO(decrypted))

    return config
开发者ID:fact-project,项目名称:credentials,代码行数:31,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python simplecrypt.encrypt函数代码示例发布时间:2022-05-27
下一篇:
Python simplecache.SimpleCache类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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