otp.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:hostapd-mana 作者: adde88 项目源码 文件源码
def parsePhrase(self, phrase):
        """Decode the phrase, and return a 64bit OTP
        I will raise Unauthorized if the parity is wrong
        TODO: Add support for hex (MUST) and the '2nd scheme'(SHOULD)"""
        words = string.split(phrase)
        for i in xrange(len(words)):
            words[i] = string.upper(words[i])
        b = 0L
        for i in xrange(0,5):
            b = b | ((long(dict.index(words[i])) << ((4-i)*11L+9L)))
        tmp = dict.index(words[5])
        b = b | (tmp & 0x7FC ) >> 2
        if (tmp & 3) <> self.calculateParity(b):
            raise Unauthorized("Parity error")
        digest = longToString(b)
        return digest
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号