You can use SHA-256 to create digest from string.
Below is code snippet for you.
String password = "password";
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(password.getBytes());
byte data[] = md.digest();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < data.length; i++) {
sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
}
System.out.println("Digest in Hex: " + sb.toString());