Quote:
Originally Posted by dummy101
Hey guys, Im having a problem storing a hashed password on a mySQL database.
Im using SHA-256 and storing a 32-byte hash in a column of type CHAR(64) but when I retrieving the same hash using the following code, it returns a different 11-byte hash.
ResultSet rs;
rs = st.executeQuery("SELECT * FROM customer_accounts WHERE nickname='" + nickname + "'");
rs.next();
byte[] h = rs.getBytes("passhash");
out.println("HashAfter: " + Arrays.toString(h) + " SaltAfter: " + Arrays.toString(s));
Any ideas what I could be doing wrong here? Thanks
1 problem was I was storing the hash as binary in a CHAR column. Now it returns the hash 32 bytes long but it is still different.
HashBefore: [86, 14, 122, 44, 61, -48, -56, -52, -55, 100, -41, -57, -76, -43, -36, 58, -104, -29, -119, -80, 122, -82, 106, -47, -11, 25, -26, 108, 28, 4, 68, 125]
HashAfter: [91, 66, 64, 53, 101, 97, 49, 53, 54, 97, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]