Why does `print hashlib.sha224(some_string).digest()` differs from its `repr()`?
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.
精彩评论