JAVA sha256 sample code
import java.security.MessageDigest;
import java.nio.charset.StandardCharsets;
public class Sha256Hash {
public static String encode(byte[] input) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(input);
StringBuilder sb = new StringBuilder();
for (byte b : hash) {
sb.append(String.format("%02x", b));
}
return sb.toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) {
String input = "1234567";
String encoded = encode(input.getBytes(StandardCharsets.UTF_8));
System.out.println("Encoded: " + encoded);
}
}