Sha256 algorithm java
import java.io.*;
import java.security.MessageDigest;
import java.util.*;
public class Solution {
public static void main(String[] args) { Scanner ab=new Scanner(System.in); String str=ab.next(); try {
// create a instance of class with Sha 256 algo
MessageDigest md=MessageDigest.getInstance("SHA-256");
md.update(str.getBytes());
// will give hash code to array
byte[] digest = md.digest();
for (byte b : digest) { System.out.printf("%02x", b); } } catch (Exception ex) { throw new RuntimeException(ex); } }
}
import java.security.MessageDigest;
import java.util.*;
public class Solution {
public static void main(String[] args) { Scanner ab=new Scanner(System.in); String str=ab.next(); try {
// create a instance of class with Sha 256 algo
MessageDigest md=MessageDigest.getInstance("SHA-256");
md.update(str.getBytes());
// will give hash code to array
byte[] digest = md.digest();
for (byte b : digest) { System.out.printf("%02x", b); } } catch (Exception ex) { throw new RuntimeException(ex); } }
}
0 Comments:
Post a Comment