search

Home  >  Q&A  >  body text

sha1 - python多字节大数的运算问题

用hashlib.sha1()计算sha1值
返回ans = h.digest()
type(ans)是'str'
len(ans)是20
ans本质上是一个160bit的大数
此时需要对不同的ans值进行xor或者取对数运算
请问有什么办法吗?

怪我咯怪我咯2878 days ago901

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-17 14:45:56

    You can take out each character in ans, use ord to get its int value, and then perform operations such as xor or logarithm

    ord('a') == 97
    chr(97) == 'a'
    

    reply
    0
  • Cancelreply