I have this code, but i can’t understand why i get this error:
a= name+pw+salt
TypeError: unsupported operand type(s) for +: '_sre.SRE_Match' and '_sre.SRE_Match'
script
class MainHandler(Handler):
def make_salt(self):
return ''.join(random.choice(string.ascii_letters) for x in range(5))
def make_pw_hash(self, name, pw):
salt = self.make_salt()
a= name+pw+salt //problem here
h = hashlib.sha256(a.encode("UTF8")).hexdigest()
return '%s|%s' % (h, salt)
def post(self):
store_hash_and_salt = self.make_pw_hash("José", "somePass")
print (store_hash_and_salt)
The problem is not there. Somewhere earlier you passed it the RE match results instead of using the
group()method to obtain the strings from them.(Also, the format of the returned string is incorrect, but that’s not the bug here.)