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.
encode64contains a newline, compare it withencode64.strip().