-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSHA1.java
More file actions
29 lines (24 loc) · 884 Bytes
/
SHA1.java
File metadata and controls
29 lines (24 loc) · 884 Bytes
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
/*********
-*- Made by VoxelPixel
-*- For YouTube Tutorial
-*- https://github.com/VoxelPixel
-*- Support me on Patreon: https://www.patreon.com/voxelpixel
*********/
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Scanner;
public class SHA1 {
public static void main(String[] args) throws NoSuchAlgorithmException {
Scanner in = new Scanner(System.in);
System.out.print("Enter message: ");
String input = in.nextLine();
MessageDigest md = MessageDigest.getInstance("SHA1");
md.update(input.getBytes());
byte[] digest = md.digest();
StringBuffer sb = new StringBuffer();
for (byte b : digest){
sb.append(String.format("%02x", b & 0xff));
}
System.out.println("SHA1 Hash: " + sb.toString());
}
}