i tried to do some password validation using sha digest in mysql database.
however, hash generated with my java code and mysql function is completely different.
mysql:
select sha('a');
86f7e437faa5a7fce15d1ddcb9eaeaea377667b8
java
MessageDigest dg=MessageDigest.getInstance("SHA-256");
byte[] b=dg.digest("a".getBytes("ISO8859_1"));
System.out.println(Arrays.toString(b));
[-54, -105, -127, 18, -54, 27, -67, -54, -6, -62, 49, -77, -102, 35, -36, 77, -89, -122, -17, -8, 20, 124, 78, 114, -71, -128, 119, -123, -81, -18, 72, -69]
these bytes are nowhere near bytes i get from mysql, how am i supposed to interpret them?
mysql char set is set to latin1, that's why i used ISO8859_1? maybe i should use some other char set when converting bytes to unicode string?
thank you!