-
Notifications
You must be signed in to change notification settings - Fork 33
/
SHA.java
49 lines (38 loc) · 1.13 KB
/
SHA.java
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
37
38
39
40
41
42
43
44
45
46
47
48
49
package cryptography.hashes.sha;
import java.security.NoSuchAlgorithmException;
import jonelo.jacksum.JacksumAPI;
import jonelo.jacksum.algorithm.AbstractChecksum;
public class SHA {
public static void main(String[] args) {
}
private static String jacksumAPI(String input, String instance) {
String output = "";
AbstractChecksum abstractChecksum = null;
try {
abstractChecksum = JacksumAPI.getChecksumInstance(instance.toLowerCase());
abstractChecksum.update(input.getBytes());
output = abstractChecksum.getFormattedValue();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return output;
}
public static String sha0(String input) {
return jacksumAPI(input, "SHA-0");
}
public static String sha1(String input) {
return jacksumAPI(input, "SHA-1");
}
public static String sha224(String input) {
return jacksumAPI(input, "SHA-224");
}
public static String sha256(String input) {
return jacksumAPI(input, "SHA-256");
}
public static String sha384(String input) {
return jacksumAPI(input, "SHA-384");
}
public static String sha512(String input) {
return jacksumAPI(input, "SHA-512");
}
}