Datasets:

ArXiv:
License:
File size: 1,073 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.io.*;
import java.util.*;
import java.math.*;
import java.security.*;

/* 
Accept any string and print its SHA256 hash value using Secure Hash Algorithm 2 (SHA-2) algorithum. It consists of six hashing algorithms from that here i used SHA-256 algorithm,
SHA-256 is a -bit ( byte) hashing algorithm which can calculate a hash code for an input of up to  bits. It undergoes  rounds of hashing and calculates a hash code that is a -digit hexadecimal number.

*/

public class SHA256Encryption
 {
  public static void main(String[] args)
	{
    try 
		{
            Scanner scanner = new Scanner(System.in);
            String word = scanner.nextLine();
            scanner.close();
            MessageDigest messageDigest = MessageDigest.getInstance( "SHA-256");
            messageDigest.update(word.getBytes("UTF-8"));
            byte[] byteHash = messageDigest.digest();
            for (byte b : byteHash)
            {
                System.out.format( "%02x", b );
            }

     } 
		catch ( Exception e )
		{
       e.printStackTrace();
    }
  }
}