I wish to convert a string to md5 and to base64. Here's what I achieved so far:
base64.urlsafe_b64encode("text..." + Var1 + "text..." +
hashlib.md5(Var2).hexdigest() + "text...")
Python raises a TypeError which says: Unicode objects must be encoded before hashing
.
Edit: This is what I have now:
var1 = "hello"
var2 = "world"
b1 = var1.encode('utf-8')
b2 = var2.encode('utf-8')
result = "text" +
base64.urlsafe_b64encode("text" + b1 + "text" +
hashlib.md5(b2).hexdigest() + "text") +
"text"