HashUtils-Hash值计算工具类
作用
本工具类主要提供不太好分类的通用工具方法。
API列表
/**
* 使用Murmur3哈希算法生成指定消息HashCode的方法
*
* @param msg 需要生成Hash值的字符串
* @param seed 自定义种子
* @return 返回Hash值
*/
public static String hashcode(byte[] message, int seed) {
// to do sth.
}
/**
* 使用Murmur3哈希算法生成指定消息HashCode的方法
*
* @param msg 需要生成Hash值的字符串
* @param seed 自定义种子
* @return 返回Hash值
*/
public static String hashcode(String message, int seed) {
// to do sth.
}
/**
* 生成指定消息的MD5码的方法
*
* @param message 需要生成MD5值的字符串
* @return 返回消息的MD5码
*/
public static String md5(byte[] message) {
// to do sth.
}
/**
* 生成指定消息的MD5码的方法
*
* @param message 需要生成MD5值的字符串
* @return 返回消息的MD5码
*/
public static String md5(String message) {
// to do sth.
}
/**
* 生成指定消息的SHA256码的方法
*
* @param message 需要生成SHA256值的字符串
* @return 返回消息的SHA256码
*/
public static String sha256(byte[] message) {
// to do sth.
}
/**
* 生成指定消息的SHA256码的方法
*
* @param message 需要生成SHA256值的字符串
* @return 返回消息的SHA256码
*/
public static String sha256(String message) {
// to do sth.
}
/**
* 生成指定消息的SHA512码的方法
*
* @param message 需要生成SHA512值的字符串
* @return 返回消息的SHA512码
*/
public static byte[] sha512(byte[] message) {
// to do sth.
}
/**
* 生成指定消息的SHA512码的方法
*
* @param message 需要生成SHA512值的字符串
* @return 返回消息的SHA512码
*/
public static byte[] sha512(String message) {
// to do sth.
}
/**
* 生成指定消息的SHA512码的方法
*
* @param message 需要生成SHA512值的字符串
* @return 返回消息的SHA512码
*/
public static String sha512WithString(byte[] message) {
// to do sth.
}
/**
* 生成指定消息的SHA512码的方法
*
* @param message 需要生成SHA512值的字符串
* @return 返回消息的SHA512码
*/
public static String sha512WithString(byte[] message) {
// to do sth.
}
/**
* 生成指定消息的SHA512码的方法
*
* @param message 需要生成SHA512值的字符串
* @return 返回消息的SHA512码
*/
public static String sha512WithString(String message) {
// to do sth.
}
/**
* 生成指定消息的Base64格式SHA512值的方法
*
* @param message 需要生成的字符串
* @return 返回BASE64格式的SHA512值
*/
public static String sha512WithBase64(byte[] message) {
// to do sth.
}
/**
* 生成指定消息的Base64格式SHA512值的方法
*
* @param message 需要生成的字符串
* @return 返回BASE64格式的SHA512值
*/
public static String sha512WithBase64(String message) {
// to do sth.
}
用法
静态工具类方法,直接使用即可。
演示
System.out.println(HashUtils.generateSHA256("Hello, World!"));