pythonにおいて、hash値を計算します。
出てくるものは、16進数ですが、文字列型で出力されます。
文字列を16進数に変換するのではなく、文字列型で表示されている16進表記を10進表記にしたいです。
下記コードのようにしたいですが、int()が通用しません(文字列を変換しようとしているから)
どなたか教えて頂けると幸いです。
python
1import matplotlib.pyplot as plt 2 3x = 0 4input = input = x.to_bytes(32, 'big') 5 6y = int(hashlib.sha256(input).hexdigest())
error
1--------------------------------------------------------------------------- 2ValueError Traceback (most recent call last) 3<ipython-input-15-a4335a2c787f> in <module>() 4 6 input = x.to_bytes(32, 'big') 5 7 6----> 8 y = int(hashlib.sha256(input).hexdigest()) 7 9 8 9ValueError: invalid literal for int() with base 10: '66687aadf862bd776c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925'
通用しないとはどうなるんでしょう
エラーが出るならエラーメッセージを提示しましょう
ご指摘ありがとうございます。
回答2件
あなたの回答
tips
プレビュー