bc sha 256
import java.math.BigInteger;
import java.security.MessageDigest;
public class checkSHA256
{
public static String getSHA(String input)
{
try
{
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] messageDigest = md.digest(input.getBytes());
BigInteger no = new BigInteger(1, messageDigest);
String hashtext = no.toString(16);
while (hashtext.length() < 32)
{
hashtext = "0" + hashtext;
}
return hashtext;
}
catch (Exception e)
{
System.out.println("Invalid algorithm: " + e);
return null;
}
}
public static void main(String args[]) throws Exception
{
System.out.println("HashCode Generated by SHA-256 for:");
String s1 = "Hello ";
System.out.println(s1+ ":" + getSHA(s1));
String s2="World";
System.out.println(s2+ ":" +getSHA(s2));
String s3=s1.concat(s2);
System.out.println(s3+":"+ getSHA(s3));
}
}