Question: Java - Cryptographic hash function: I need to implement the method Digest.java(code below), this main method should compute and print the hash digest of the
Java - Cryptographic hash function:
I need to implement the method Digest.java(code below), this main method should compute and print the hash digest of the string "test message to be hashed" using SHA-256 algorithm. I need to use the class MessageDigest.
Sample output:
The digest of "test message to be hashed" is
uXi/fCgWC8h6cv0FKBKpemeyerRH1hAT9+HiwOu5dm4=
Code so far:
package lecture8;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
public class Digest {
/*
* print out the hash digest of the string
* "test message to be hashed" using the SHA-256 algorithm
*/
public static void main(String[] args) {
// TODO
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
