Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Commit 642b811

Browse files
authored
Add files via upload
1 parent 27358db commit 642b811

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

usacotools.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
*
55
*/
66
import java.util.*;
7+
78
import java.io.*;
9+
import java.security.*;
810
public abstract class usacotools {
911
public static final String ANSI_RESET = "\u001B[0m";
1012
public static final String ANSI_BLACK = "\u001B[30m";
@@ -422,6 +424,26 @@ public static void LOCK() {
422424
public static void UNLOCK() {
423425
if(!(_lock)) {lock=false;}
424426
}
427+
public static String sha256(String input) throws NoSuchAlgorithmException {
428+
MessageDigest md = MessageDigest.getInstance("SHA-256");
429+
byte[] result = md.digest(input.getBytes());
430+
StringBuffer s = new StringBuffer();
431+
for (int i = 0; i < result.length; i++) {
432+
s.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
433+
}
434+
435+
return s.toString();
436+
}
437+
public static String sha(String input,String type) throws NoSuchAlgorithmException {
438+
MessageDigest md = MessageDigest.getInstance(type);
439+
byte[] result = md.digest(input.getBytes());
440+
StringBuffer s = new StringBuffer();
441+
for (int i = 0; i < result.length; i++) {
442+
s.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
443+
}
444+
445+
return s.toString();
446+
}
425447

426448
public static void main(String[] args) throws Exception{
427449
print("the demo has been removed do to lack of support. Instead we display info about the library.");

utools.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
*
55
*/
66
import java.util.*;
7+
78
import java.io.*;
9+
import java.security.*;
810
public abstract class utools {
911
public static final String ANSI_RESET = "\u001B[0m";
1012
public static final String ANSI_BLACK = "\u001B[30m";
@@ -422,6 +424,26 @@ public static void LOCK() {
422424
public static void UNLOCK() {
423425
if(!(_lock)) {lock=false;}
424426
}
427+
public static String sha256(String input) throws NoSuchAlgorithmException {
428+
MessageDigest md = MessageDigest.getInstance("SHA-256");
429+
byte[] result = md.digest(input.getBytes());
430+
StringBuffer s = new StringBuffer();
431+
for (int i = 0; i < result.length; i++) {
432+
s.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
433+
}
434+
435+
return s.toString();
436+
}
437+
public static String sha(String input,String type) throws NoSuchAlgorithmException {
438+
MessageDigest md = MessageDigest.getInstance(type);
439+
byte[] result = md.digest(input.getBytes());
440+
StringBuffer s = new StringBuffer();
441+
for (int i = 0; i < result.length; i++) {
442+
s.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
443+
}
444+
445+
return s.toString();
446+
}
425447

426448
public static void main(String[] args) throws Exception{
427449
print("the demo has been removed do to lack of support. Instead we display info about the library.");

0 commit comments

Comments
 (0)