This repository was archived by the owner on Feb 29, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 4
4
*
5
5
*/
6
6
import java .util .*;
7
+
7
8
import java .io .*;
9
+ import java .security .*;
8
10
public abstract class usacotools {
9
11
public static final String ANSI_RESET = "\u001B [0m" ;
10
12
public static final String ANSI_BLACK = "\u001B [30m" ;
@@ -422,6 +424,26 @@ public static void LOCK() {
422
424
public static void UNLOCK () {
423
425
if (!(_lock )) {lock =false ;}
424
426
}
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
+ }
425
447
426
448
public static void main (String [] args ) throws Exception {
427
449
print ("the demo has been removed do to lack of support. Instead we display info about the library." );
Original file line number Diff line number Diff line change 4
4
*
5
5
*/
6
6
import java .util .*;
7
+
7
8
import java .io .*;
9
+ import java .security .*;
8
10
public abstract class utools {
9
11
public static final String ANSI_RESET = "\u001B [0m" ;
10
12
public static final String ANSI_BLACK = "\u001B [30m" ;
@@ -422,6 +424,26 @@ public static void LOCK() {
422
424
public static void UNLOCK () {
423
425
if (!(_lock )) {lock =false ;}
424
426
}
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
+ }
425
447
426
448
public static void main (String [] args ) throws Exception {
427
449
print ("the demo has been removed do to lack of support. Instead we display info about the library." );
You can’t perform that action at this time.
0 commit comments