I try to compare value after encode base64 with string. But encode64
does not equal to Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=
Why does not it equal ?
import hashlib
hash_object = hashlib.sha256(b'Test')
hex_dig = hash_object.hexdigest()
encode64 = hex_dig.decode('hex').encode('base64')
print(encode64)
if encode64 == 'Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=' :
print("Hello")
Output
Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=
It does not print Hello.
There's a '\\n' in the end of encode64 variable. You can do
if encode64.strip() == 'Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=' :
print("Hello")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.