java md5工具類分享
import javasecurityMessageDigest;
import javasecurityNoSuchAlgorithmException;
/**
* MD5工具類
*
* @author
* @version 0
*/
public class Md5Util {
/**
* Md
*
* @param value the value
* @return the string
*/
public static String md5(String value) {
try {
MessageDigest md = MessageDigestgetInstance("md5");
byte[] e = mddigest(valuegetBytes());
return toHex(e);
}
catch (NoSuchAlgorithmException e) {
eprintStackTrace();
return value;
}
}
/**
* Md
*
* @param bytes the bytes
* @return the string
*/
public static String md5(byte[] bytes){
try {
MessageDigest md = MessageDigestgetInstance("md5");
byte[] e = mddigest(bytes);
return toHex(e);
}
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return "";
}
}
/**
* To hex
*
* @param bytes the bytes
* @return the string
*/
private static String toHex(byte bytes[]){
StringBuilder hs = new StringBuilder();
String stmp ="";
for (int n = 0; n < byteslength; n++) {
stmp = IntegertoHexString(bytes[n] & 0xff);
if (stmplength() == 1)
hsappend("0")append(stmp);
else
hsappend(stmp);
}
return hstoString();
}
}
相關(guān)文章
Java原生方法實(shí)現(xiàn) AES 算法示例
這篇文章主要介紹了Java原生方法實(shí)現(xiàn) AES 算法,結(jié)合實(shí)例形式分析了Java實(shí)現(xiàn)AES加密算法的相關(guān)操作技巧,需要的朋友可以參考下2019-03-03spring boot 2.x html中引用css和js失效問(wèn)題及解決方法
這篇文章主要介紹了spring boot 2.x html中引用css和js失效,需要的朋友可以參考下2018-11-11MyBatis在insert插入操作時(shí)返回主鍵ID的配置(推薦)
這篇文章主要介紹了MyBatis在insert插入操作時(shí)返回主鍵ID的配置的相關(guān)資料,需要的朋友可以參考下2017-10-10基于CyclicBarrier和CountDownLatch的使用區(qū)別說(shuō)明
這篇文章主要介紹了基于CyclicBarrier和CountDownLatch的使用區(qū)別說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-09-09SpringBoot整合SpringSecurity實(shí)現(xiàn)權(quán)限控制之實(shí)現(xiàn)多標(biāo)簽頁(yè)
這篇文章主要介紹了SpringBoot整合SpringSecurity實(shí)現(xiàn)權(quán)限控制之實(shí)現(xiàn)多標(biāo)簽頁(yè),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-11-11JAVA實(shí)現(xiàn)網(wǎng)絡(luò)/本地圖片轉(zhuǎn)BASE64存儲(chǔ)代碼示例
這篇文章主要給大家介紹了關(guān)于JAVA實(shí)現(xiàn)網(wǎng)絡(luò)/本地圖片轉(zhuǎn)BASE64存儲(chǔ)的相關(guān)資料,Base64是網(wǎng)絡(luò)上最常見(jiàn)的用于傳輸8Bit字節(jié)碼的編碼方式之一,Base64就是一種基于64個(gè)可打印字符來(lái)表示二進(jìn)制數(shù)據(jù)的方法,需要的朋友可以參考下2023-07-07SpringBoot工程啟動(dòng)順序與自定義監(jiān)聽(tīng)超詳細(xì)講解
這篇文章主要介紹了SpringBoot工程啟動(dòng)順序與自定義監(jiān)聽(tīng),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧2022-11-11