MD5加密工具,md5加密

來源:互聯網
上載者:User

MD5加密工具,md5加密

package com.liujun.util;import java.security.MessageDigest;/** * MD5加密、匹配工具 * @author asus * */public class MD5Util {//十六進位下數字到字元的映射數組private final static String[] hexDigits={"0", "1", "2", "3", "4",          "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};/** * 將一個位元組裝換成十六進位形式的字串 * @param b十六進位位元組 * @return十六進位字串 */private static String byteToHexStr(byte b){int n=b;if(n<0){n=256+n;}int d1=n/16;int d2=n%16;return hexDigits[d1]+hexDigits[d2];}/** * 將位元組數群組轉換成十六進位字串 * @param bytes位元組數組 * @return十六進位字串 */private static String byteArrayToHexStr(byte[] bytes){StringBuffer sb=new StringBuffer();for (int i = 0; i < bytes.length; i++) {sb.append(byteToHexStr(bytes[i]));}return sb.toString();}/** * 對字串進行MD5加密 * @param originStr原始密碼 * @returnMD5加密密碼串 */public static String encodeToMd5Str(String originStr){if (originStr!=null) {try {//建立MD5演算法資訊MessageDigest messageDigest=MessageDigest.getInstance("MD5");//將原始密碼加密轉換成MD5位元組數組byte[] md5Bytes=messageDigest.digest(originStr.getBytes());//將加密後的位元組數群組轉換成字串String resultStr=byteArrayToHexStr(md5Bytes);//轉換成大寫return resultStr.toUpperCase();} catch (Exception e) {e.printStackTrace();}}return null;}/** * 最字串進行MD5密碼匹配 * @param md5Str * @param originStr * @return */public static boolean validatePassword(String md5Str,String originStr){if (md5Str.equals(encodeToMd5Str(originStr))) {return true;}else {return false;}}}
package com.liujun.main;import com.liujun.util.MD5Util;public class Main {public static void main(String[] args) {//原始密碼String orginStr="12345";//MD5加密密碼String md5Str;//將原始密碼產生MD5密碼md5Str=MD5Util.encodeToMd5Str(orginStr);System.out.println("原始密碼:"+orginStr);System.out.println("MD5加密密碼:"+md5Str);//驗證密碼是否正確if (MD5Util.validatePassword(md5Str, orginStr)) {System.out.println("密碼匹配成功");}else{System.out.println("密碼匹配失敗");}}}
源碼:http://download.csdn.net/detail/u010739551/7875377






md5加密工具

www.zou.la/hasher/,這個挺不錯,支援md5驗證
 
md5線上解密是什

你的MD5不需要解密,而且也不可能解密.MD5解密最常用的是用MD5加密過的密碼,解密是為了知道密碼的原文.
而網上下載的檔案計算出來的MD5主要是用來校正檔案是否與發行是一致,如果不一致,可能檔案被病毒感染或是被修改過.
你可以聯絡一下網遊的客服,可能你下載的檔案有問題,也有可能是網站在更新了檔案以後忘了修改MD5了.
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.