广州市综治平台后端
xusd
2025-06-07 36306491396230522fa20585c2621a7fc899849a
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package cn.huge.gateway.utils;
 
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
 
/**
 * @title: 转码工具类
 * @description: 需要对字符串Base64/MD5/SHA1/SHA256可直接调用此类方法实现
 * @company: hugeinfo
 * @author: liyj
 * @time: 2021-11-05 16:51:48
 * @version: 1.0.0
 */
public class EncryptionUtils   {
 
    public static void main( String[] args ) {
 
    }
 
    /**
     * 对字符串Base64加密
     * @param data 需要加密的字符串
     * @return 返回字符串Base64加密后的字符串
     */
    public static String base64Encode( String data ) {
        return Base64.encodeBase64String( data.getBytes() );
    }
 
    /**
     * 字符串Base64解密
     * @param data 需要加密的字符串
     * @return 返回解密后的字节数组 
     */
    public static byte[] base64Decode( String data ) {
        return Base64.decodeBase64( data.getBytes() );
    }
 
    /**
     * 对字符串进行MD5加密 此加密方法不可逆
     * @param data 需要加密的字符串
     * @return String
     */
    public static String md5( String data ) {
        return DigestUtils.md5Hex( data );
    }
 
    /**
     * 对字符串进行SHA1加密
     * @param data 需要加密的字符串
     * @return String
     */
    public static String sha1( String data ) {
        return DigestUtils.shaHex( data );
    }
 
    /**
     * 对字符串进行SHA256加密
     * @param data 需要加密的字符串
     * @return String
     */
    public static String sha256Hex( String data ) {
        return DigestUtils.sha256Hex( data );
    }
}
/**
 * -------------------_ooOoo_-------------------
 * ------------------o8888888o------------------
 * ------------------88" . "88------------------
 * ------------------(| -_- |)------------------
 * ------------------O\  =  /O------------------
 * ---------------____/`---'\____---------------
 * -------------.'  \\|     |//  `.-------------
 * ------------/  \\|||  :  |||//  \------------
 * -----------/  _||||| -:- |||||-  \-----------
 * -----------|   | \\\  -  /// |   |-----------
 * -----------| \_|  ''\---/''  |   |-----------
 * -----------\  .-\__  `-`  ___/-. /-----------
 * ---------___`. .'  /--.--\  `. . __----------
 * ------."" '<  `.___\_<|>_/___.'  >'"".-------
 * -----| | :  `- \`.;`\ _ /`;.`/ - ` : | |-----
 * -----\  \ `-.   \_ __\ /__ _/   .-` /  /-----
 * ======`-.____`-.___\_____/___.-`____.-'======
 * -------------------`=---='
 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 * ---------佛祖保佑---hugeinfo---永无BUG----------
 */