java - Hashing password using salt -


i producing hashed value of password salt.my code:

  `string psw="hello";      string tobehashed="";    tobehashed=salt+psw;    messagedigest md = messagedigest.getinstance("sha-256");    byte[] digest = md.digest(tobehashed.getbytes());    system.out.println("digest:"+digest);`  

i have produced salt providing seed current time in milliseconds,i have no issues salt(i m getting random values) irrespective of salt getting same hash value..

actually purpose of salt different hash values.. output; random nubr:-2098016229(this keeps changing) digest:[b@ca0b6(this remains same) waht solution??

you printing out result of digest.tostring(), in case of byte array not convert bytes meaningful output. prints [b (which code byte array), @, , hex address. see output more experience java.

you need use loop iterate through bytes in digest , print them individually.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -