一 MD5 概述
MD5消息摘要算法(英語:MD5 Message-Digest Algorithm),一種被廣泛使用的密碼散列函數,可以產生出一個128位(16字節)的散列值(hash value),用於確保信息傳輸完整一致。MD5由美國密碼學家羅納德·李維斯特(Ronald Linn Rivest)設計,於1992年公開,用以取代MD4算法。
二 代碼
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>jQuery MD5 加密</title> <script src="jquery-1.12.3.js"></script> <script src="jQuery.md5.js"></script> <script> function print() { // 加密密碼 let username = $('#username').val(); let password = $('#password').val(); let str = username + '#' + password; let ciphertext = $.md5(str); $('#ciphertext').text(ciphertext); // 模擬登錄 $.ajax({ type: "post", url: "http://www.qq.com", async: true, cache: false, data: { username: username, password: ciphertext } }); } </script> </head> <body> <!--登錄表單--> <input type="text" id='username' placeholder="請輸入用戶名" /> <input type="password" id="password" placeholder="請輸入密碼" /> <button onclick="print();">確定</button> <!--展示密文--> <div id="ciphertext"> </div> </body> </html>
三 運行結果
輸入admin和123456,點擊確定按鈕。
四 在線解密
常見的口令、弱口令可以立即解密。