The first snippet is
String password = "test1111";
MessageDigest sha = MessageDigest.getInstance("SHA-1");
sha.update(password.getBytes());
return sha.digest();
The byte array returned is an array of 20 bytes with values
byte[] = { -89, 67, -10, 0, 65, -120, -61, -124, -37, -11, 102, -64, -127, 28, -96, -55, 120, -32, 122, -101 };
On the other hand,
select sha1('test1111');
in the MySQL database results in
mysql> select sha1('test1111');
+------------------------------------------+
| sha1('test1111') |
+------------------------------------------+
| a743f6004188c384dbf566c0811ca0c978e07a9b |
+------------------------------------------+
1 row in set (0.00 sec)
Why are they different?