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
Post a Comment