public abstract class Encrypter extends Object
| 构造器和说明 |
|---|
Encrypter() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
bytes2Hex(byte[] bytes)
将指定字节数组转为十六进制形式的字符串
数组不能为null,否则引发空指针异常 |
static String |
bytes2Hex(byte[] bytes,
int start,
int end)
将指定字节数组转为十六进制形式的字符串
数组不能为null,否则引发空指针异常 |
static byte[] |
desDecode(String key,
byte[] dest)
使用DES可逆算法以指定的密钥字符串对指定字节数组进行解密,并返回解密后的字节数组
注意:本方法每次都产生一个新的DES实例,如果密钥是固定的或者加密、解密都是成对使用,建议直接使用easymapping.util.DES |
static String |
desDecode(String key,
String dest)
使用DES可逆算法以指定的密钥字符串对指定字符串进行解密,并返回解密后的字符串
注意:本方法每次都产生一个新的DES实例,如果密钥是固定的或者加密、解密都是成对使用,建议直接使用easymapping.util.DES |
static byte[] |
desEncode(String key,
byte[] input)
使用DES可逆算法以指定的密钥字符串对指定字节数组进行加密,并返回加密后的字节数组
注意:本方法每次都产生一个新的DES实例,如果密钥是固定的或者加密、解密都是成对使用,建议直接使用easymapping.util.DES |
static String |
desEncode(String key,
String input)
使用DES可逆算法以指定的密钥字符串对指定字符串进行加密,并返回加密后的字符串
注意:本方法每次都产生一个新的DES实例,如果密钥是固定的或者加密、解密都是成对使用,建议直接使用easymapping.util.DES |
static byte[] |
encode(byte[] buf,
String algorithm)
以指定的算法对指定的字节数组进行加密运算,并返回加密后的字节数组
注意:算法名称必须是MessageDigest对象支持的算法,否则可能引发异常 |
static String |
encode(String input,
String algorithm)
以指定的算法对指定的字符串进行加密运算,并返回加密后的十六进制的字符串值
注意:算法名称必须是MessageDigest对象支持的算法,否则可能引发异常 |
static MessageDigest |
getMessageDigest(String algorithm)
获取对应的摘要算法
|
static byte[] |
md5(byte[] buf)
将指定的字节数组通过MD5加密算法进行加密,并返回加密后的32位MD5值
如果数组为null,则引发空指针异常 |
static String |
md5(String input)
将指定的字符串通过MD5加密算法进行加密,并返回加密后32位的MD5值
如果字符串为null,将引发空指针异常 |
static String |
md5For16(String input)
将指定的字符串通过MD5加密算法进行加密,并返回加密后16位的MD5值
为了保持一致,内部统一使用UTF-8编码获取字符串的字节数组 如果字符串为null,将引发空指针异常 |
static byte[] |
sha1(byte[] buf)
将指定的字节数组通过SHA-1加密算法进行加密,并返回加密后的字节数组
如果数组为null,则引发空指针异常 |
static String |
sha1(String input)
将指定的字符串通过SHA-1加密算法进行加密,并返回加密后的40位SHA-1值
为了保持一致,内部统一使用UTF-8编码获取字符串的字节数组 如果字符串为null,将引发空指针异常 |
public static final MessageDigest getMessageDigest(String algorithm)
public static final String md5(String input)
public static final String md5For16(String input)
public static final byte[] md5(byte[] buf)
public static final String sha1(String input)
public static final byte[] sha1(byte[] buf)
public static final String desEncode(String key, String input)
key - 指定的密钥字符串input - 需要加密的字符串public static final String desDecode(String key, String dest)
key - 指定的密钥字符串dest - 需要加密的字符串public static final byte[] desEncode(String key, byte[] input)
key - 指定的密钥字符串input - 需要加密的字节数组public static final byte[] desDecode(String key, byte[] dest)
key - 指定的密钥字符串dest - 需要解密的字节数组public static final byte[] encode(byte[] buf,
String algorithm)
buf - 指定的字节数组algorithm - 算法名称public static final String encode(String input, String algorithm)
input - 指定的字符串algorithm - 算法名称,如“MD5”、“SHA”、“SHA-256”、“SHA-384”、“SHA-512”。public static final String bytes2Hex(byte[] bytes)
public static final String bytes2Hex(byte[] bytes, int start, int end)
bytes - 指定的字节数组start - 开始转换的索引end - 结束转换的索引Copyright © 2019. All rights reserved.