Skip to content

Commit

Permalink
Merge message digest util classes
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyesiqiu committed Apr 4, 2024
1 parent 6685a60 commit 9539519
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 36 deletions.
16 changes: 0 additions & 16 deletions dpt/src/main/java/com/luoye/dpt/util/Md5Utils.java

This file was deleted.

22 changes: 22 additions & 0 deletions dpt/src/main/java/com/luoye/dpt/util/MessageDigestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @author luoyesiqiu
*/
public class MessageDigestUtils {
private static final String ALGORITHM_MD5 = "md5";
private static final String ALGORITHM_SHA256 = "sha-256";
public static String hash(String algorithm,byte[] input){
StringBuilder ret = new StringBuilder();
try {
Expand All @@ -26,4 +28,24 @@ public static String hash(String algorithm,byte[] input){
}
return ret.toString();
}

public static String md5(byte[] input){
return hash(ALGORITHM_MD5,input);
}

public static String shortMd5(byte[] input){
return md5(input).substring(8,24);
}

public static String sha256(byte[] input){
return hash(ALGORITHM_SHA256,input);
}

public static String shortSha256Left(byte[] input) {
return sha256(input).substring(0,32);
}

public static String shortSha256Right(byte[] input) {
return sha256(input).substring(32,64);
}
}
20 changes: 0 additions & 20 deletions dpt/src/main/java/com/luoye/dpt/util/ShaUtils.java

This file was deleted.

0 comments on commit 9539519

Please sign in to comment.