Difference between android sha224 and python sha224 -


for application prototype i'm creating simple user login. password of user hashed using sha224 , transferred back-end. problem facing right following. password stored in db (also hashed using sha224) seems little different hash sending. use following code create hashes.

given password == test

python

from hashlib import sha224 sha224("test").hexdigest() 

android

messagedigest sha224 = messagedigest.getinstance("sha-224"); sha224.update(key.getbytes());  byte[] digest = sha224.digest(); stringbuffer buffer = new stringbuffer();  for(int = 0; < digest.length; i++) {  buffer.append(string.valueof(integer.tohexstring(0xff & digest[i]))); }  return buffer.tostring(); 

what produced looks , post 2 hashes directly underneath each other. (the first 1 python , second android)

90a3ed9e32b2aaf4c61c410eb925426119e1a9dc53d4286ade99a809 90a3ed9e32b2aaf4c61c41eb925426119e1a9dc53d4286ade99a89

they same python hash has 2 0s more. guys have idea why?

you're not formatting hex values on android properly; leading 0s being dropped.

buffer.append(string.format("%02x", 0xff & digest[i])); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -