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


Python md5.md5方法代码示例

本文整理汇总了Python中md5.md5方法的典型用法代码示例。如果您正苦于以下问题:Python md5.md5方法的具体用法?Python md5.md5怎么用?Python md5.md5使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在md5的用法示例。


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

示例1: __init__

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def __init__(self, tpl, page):
        """
        :param tpl: a mwparserfromhell template: the original template
                that we want to change
        """
        self.template = tpl
        self.orig_string = unicode(self.template)
        r = md5.md5()
        r.update(self.orig_string.encode('utf-8'))
        self.orig_hash = r.hexdigest()
        self.classification = None
        self.conflicting_value = ''
        self.proposed_change = ''
        self.proposed_link = None
        self.index = None
        self.page = page
        self.proposed_link_policy = None
        self.issn = None 
开发者ID:dissemin,项目名称:oabot,代码行数:20,代码来源:main.py

示例2: compute

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def compute(self, ha1, username, response, method,
                      path, nonce, nc, cnonce, qop):
        """ computes the authentication, raises error if unsuccessful """
        if not ha1:
            return self.build_authentication()
        ha2 = md5('%s:%s' % (method, path)).hexdigest()
        if qop:
            chk = "%s:%s:%s:%s:%s:%s" % (ha1, nonce, nc, cnonce, qop, ha2)
        else:
            chk = "%s:%s:%s" % (ha1, nonce, ha2)
        if response != md5(chk).hexdigest():
            if nonce in self.nonce:
                del self.nonce[nonce]
            return self.build_authentication()
        pnc = self.nonce.get(nonce,'00000000')
        if nc <= pnc:
            if nonce in self.nonce:
                del self.nonce[nonce]
            return self.build_authentication(stale = True)
        self.nonce[nonce] = nc
        return username 
开发者ID:linuxscout,项目名称:mishkal,代码行数:23,代码来源:digest.py

示例3: latex2html

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def latex2html(node, source):
    inline = isinstance(node.parent, nodes.TextElement)
    latex = node['latex']
    name = 'math-%s' % md5(latex.encode()).hexdigest()[-10:]

    destdir = os.path.join(setup.app.builder.outdir, '_images', 'mathmpl')
    if not os.path.exists(destdir):
        os.makedirs(destdir)
    dest = os.path.join(destdir, '%s.png' % name)
    path = os.path.join(setup.app.builder.imgpath, 'mathmpl')

    depth = latex2png(latex, dest, node['fontset'])

    if inline:
        cls = ''
    else:
        cls = 'class="center" '
    if inline and depth != 0:
        style = 'style="position: relative; bottom: -%dpx"' % (depth + 1)
    else:
        style = ''

    return '<img src="%s/%s.png" %s%s/>' % (path, name, cls, style) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:mathmpl.py

示例4: _get_video

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def _get_video(self, sid, eid, ehash):
        myhash = hashlib.md5(
            str(self.client.token) + \
            str(eid) + \
            str(sid) + \
            str(ehash)
        ).hexdigest()

        data = {
            "eid": eid,
            "hash": myhash
        }
        result = self.client.request(self.PLAY_EPISODES_URL.format(eid=eid), data)

        if not isinstance(result, dict) or result.get("ok", 0) == 0:
            raise SoapException("Bad getting videolink")

        return result 
开发者ID:Soap4me,项目名称:Kodi,代码行数:20,代码来源:addon.py

示例5: setnonce

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def setnonce(self, text=None):
        """
        Set I{nonce} which is arbitraty set of bytes to prevent
        reply attacks.
        @param text: The nonce text value.
            Generated when I{None}.
        @type text: str
        """
        if text is None:
            s = []
            s.append(self.username)
            s.append(self.password)
            s.append(Token.sysdate())
            m = sha56()
            m.update(':'.join(s).encode("utf-8"))
            self.nonce = m.hexdigest()
        else:
            self.nonce = text 
开发者ID:cackharot,项目名称:suds-py3,代码行数:20,代码来源:wsse.py

示例6: md5_hexdigest

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def md5_hexdigest(file):
    """
    Calculate and return the MD5 checksum for a given file.
    ``file`` may either be a filename or an open stream.
    """
    if isinstance(file, basestring):
        file = open(file, 'rb')

    md5_digest = md5()
    while True:
        block = file.read(1024*16) # 16k blocks
        if not block: break
        md5_digest.update(block)
    return md5_digest.hexdigest()

# change this to periodically yield progress messages?
# [xx] get rid of topdir parameter -- we should be checking
# this when we build the index, anyway. 
开发者ID:blackye,项目名称:luscan-devel,代码行数:20,代码来源:downloader.py

示例7: __init__

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def __init__(self, d):
        self.data = d
        self.author = d.get('author')
        if 'filename' in d:
            self.filename = d['filename']
            self.base = self.filename[:-3]
        else:
            raise RuntimeError('mod without filename')
        if 'name' in d:
            self.name = d['name']
        else:
            self.name = self.filename
        if 'md5' in d:
            self.md5 = d['md5']
        else:
            raise RuntimeError('mod without md5')

        self.changelog = d.get('changelog', [])
        self.old_md5s = d.get('old_md5s', [])
        self.category = d.get('category', None)
        self.requires = d.get('requires', [])
        self.supports = d.get('supports', [])
        self.tag = d.get('tag', None) 
开发者ID:Mrmaxmeier,项目名称:BombSquad-Community-Mod-Manager,代码行数:25,代码来源:modManager.py

示例8: signature

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def signature(self):
        try:
            from hashlib import md5
        except ImportError:
            from md5 import md5
        try:
            sig = md5()
            if self.start:
                sig.update(self.start.encode('latin-1'))
            if self.prec:
                sig.update("".join(["".join(p) for p in self.prec]).encode('latin-1'))
            if self.tokens:
                sig.update(" ".join(self.tokens).encode('latin-1'))
            for f in self.pfuncs:
                if f[3]:
                    sig.update(f[3].encode('latin-1'))
        except (TypeError,ValueError):
            pass
        return sig.digest()

    # -----------------------------------------------------------------------------
    # validate_modules()
    #
    # This method checks to see if there are duplicated p_rulename() functions
    # in the parser module file.  Without this function, it is really easy for
    # users to make mistakes by cutting and pasting code fragments (and it's a real
    # bugger to try and figure out why the resulting parser doesn't work).  Therefore,
    # we just do a little regular expression pattern matching of def statements
    # to try and detect duplicates.
    # ----------------------------------------------------------------------------- 
开发者ID:nojanath,项目名称:SublimeKSP,代码行数:32,代码来源:yacc.py

示例9: calculate_digest

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def calculate_digest(ip, timestamp, secret, userid, tokens, user_data):
    secret = maybe_encode(secret)
    userid = maybe_encode(userid)
    tokens = maybe_encode(tokens)
    user_data = maybe_encode(user_data)
    digest0 = md5(
        encode_ip_timestamp(ip, timestamp) + secret + userid + '\0'
        + tokens + '\0' + user_data).hexdigest()
    digest = md5(digest0 + secret).hexdigest()
    return digest 
开发者ID:linuxscout,项目名称:mishkal,代码行数:12,代码来源:auth_tkt.py

示例10: digest_password

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def digest_password(realm, username, password):
    """ construct the appropriate hashcode needed for HTTP digest """
    return md5("%s:%s:%s" % (username, realm, password)).hexdigest() 
开发者ID:linuxscout,项目名称:mishkal,代码行数:5,代码来源:digest.py

示例11: build_authentication

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def build_authentication(self, stale = ''):
        """ builds the authentication error """
        nonce  = md5(
            "%s:%s" % (time.time(), random.random())).hexdigest()
        opaque = md5(
            "%s:%s" % (time.time(), random.random())).hexdigest()
        self.nonce[nonce] = None
        parts = {'realm': self.realm, 'qop': 'auth',
                 'nonce': nonce, 'opaque': opaque }
        if stale:
            parts['stale'] = 'true'
        head = ", ".join(['%s="%s"' % (k, v) for (k, v) in parts.items()])
        head = [("WWW-Authenticate", 'Digest %s' % head)]
        return HTTPUnauthorized(headers=head) 
开发者ID:linuxscout,项目名称:mishkal,代码行数:16,代码来源:digest.py

示例12: md5test

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def md5test(self, s, expected):
        self.assertEqual(hexstr(md5(s).digest()), expected)
        self.assertEqual(md5(s).hexdigest(), expected) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:5,代码来源:test_md5.py

示例13: test_hexdigest

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def test_hexdigest(self):
        # hexdigest is new with Python 2.0
        m = md5('testing the hexdigest method')
        h = m.hexdigest()
        self.assertEqual(hexstr(m.digest()), h) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_md5.py

示例14: test_large_update

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def test_large_update(self):
        aas = 'a' * 64
        bees = 'b' * 64
        cees = 'c' * 64

        m1 = md5()
        m1.update(aas)
        m1.update(bees)
        m1.update(cees)

        m2 = md5()
        m2.update(aas + bees + cees)
        self.assertEqual(m1.digest(), m2.digest()) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_md5.py

示例15: _get_path

# 需要导入模块: import md5 [as 别名]
# 或者: from md5 import md5 [as 别名]
def _get_path(self, key):
        md5 = hashlib.md5()
        md5.update(key)
        return os.path.join(self.cache_dir, md5.hexdigest()) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:6,代码来源:cache.py


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