You can also do this in 1 or 2 lines eg.

return hashlib.sha256(serialized_profile).hexdigest()  
or  
hasher = hashlib.sha256(serialized_profile) 
return hasher.hexdigest()