开发者

Why does `print hashlib.sha224(some_string).digest()` differs from its `repr()`?

开发者 https://www.devze.com 2023-03-29 17:04 出处:网络
I want to store some hashes of some strings in my Database table. For that I created a column of type varchar(64). I do generate the hashes like this:

I want to store some hashes of some strings in my Database table. For that I created a column of type varchar(64). I do generate the hashes like this:

>>> thehash = hashlib.sha224(some_string).digest()

Now I realize that

>>> print thehash

is not the same as

>>> thehash

(By now, I know the difference between >>> prin开发者_StackOverflow社区t 'test' and >>> 'test'... :-)) I am confused which part I should store now. The repr() or the other version?


Neither. You should call the .hexdigest() method instead and store that.

0

精彩评论

暂无评论...
验证码 换一张
取 消