I have the following code and I want a Java string from a SHA256 hash string. Is there a way to convert hex string to its original value?
public class CryptoHash {
public static void main( String[] args ) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance( "SHA-256" );
String text = "Text to hash, cryptographically.";
// Change this to UTF-16 if needed
md.update( text.getBytes( StandardCharsets.UTF_8 ) );
byte[] digest = md.digest();
String hex = String.format( "%064x", new BigInteger( 1, digest ) );
System.out.println( hex );
}
}