I am trying to hash my users password which is of string type using SHA-256
I am using SHA-256 to hash the string using the following method
String text = "abc";
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(text.getBytes("UTF-8"));
To convert the btye array to string , I used the following method
String doc2 = new String(hash, "UTF-8");
When i print doc2 to output , i get rubbish
�x����AA@�]�"#�a��z���a�
What am i doing wrong ??? How do i hash a string using SHA-256 and convert it back to string ??