Javascript client-generated MD5 Value Function Code _ javascript skills

Source: Internet
Author: User
The client implemented by js can implement the md5 value code. Generally, it is only available in the background language, and the client also has it, making it easy for friends who need it. Test code:

<Script language = javascript>/** A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. * Copyright (C) Paul Johnston 1999-2000. * Updated by Greg Holt 2000-2001. * See http://pajhome.org.uk/site/legal.html For details. */var hex_chr = "0123456789 abcdef"; function rhex (num) {str = ""; for (j = 0; j <= 3; j ++) str + = hex_chr.charAt (num> (j * 8 + 4) & 0x0F) + hex_chr.charAt (num> (j * 8) & 0x0F ); return str;} function str2blks_MD5 (str) {nblk = (str. length + 8)> 6) + 1; blks = new Array (nblk * 16); for (I = 0; I <nblk * 16; I ++) blks [I] = 0; for (I = 0; I <str. length; I ++) blks [I> 2] | = st R. charCodeAt (I) <(I % 4) * 8); blks [I> 2] | = 0x80 <(I % 4) * 8 ); blks [nblk * 16-2] = str. length * 8; return blks;} function add (x, y) {var lsw = (x & 0 xFFFF) + (y & 0 xFFFF ); var msw = (x> 16) + (y> 16) + (lsw> 16); return (msw <16) | (lsw & 0 xFFFF );} function rol (num, cnt) {return (num <cnt) | (num> (32-cnt);} function CEN (q, a, B, x, s, t) {return add (rol (add (, Q), add (x, t), s), B);} function ff (a, B, c, d, x, s, t) {return CEN (B & c) | ((~ B) & d), a, B, x, s, t);} function gg (a, B, c, d, x, s, t) {return CEN (B & d) | (c &(~ D), a, B, x, s, t);} function hh (a, B, c, d, x, s, t) {return CEN (B ^ c ^ d, a, B, x, s, t);} function ii (a, B, c, d, x, s, t) {return CEN (c ^ (B | (~ D), a, B, x, s, t);} function MD5 (str) {x = str2blks_MD5 (str); var a = 1732584193; var B =-271733879; var c =-1732584194; var d = 271733878; for (I = 0; I <x. length; I + = 16) {var olda = a; var oldb = B; var oldc = c; var oldd = d; a = ff (a, B, c, d, x [I + 0], 7,-680876936); d = ff (d, a, B, c, x [I + 1], 12,-389564586 ); c = ff (c, d, a, B, x [I + 2], 17,606 105819); B = ff (B, c, d,, x [I + 3], 22,-1044525330); a = ff (a, B, c, d, x [I + 4], 7,-176418897 ); d = ff (d, a, B, c, x [I + 5], 12,120 0080426); c = ff (c, d, a, B, x [I + 6], 17,-1473231341); B = ff (B, c, d, a, x [I + 7], 22,-45705983 ); a = ff (a, B, c, d, x [I + 8], 7, 1770035416); d = ff (d, a, B, c, x [I + 9], 12,-1958414417); c = ff (c, d, a, B, x [I + 10], 17,-42063 ); B = ff (B, c, d, a, x [I + 11], 22,-1990404162); a = ff (a, B, c, d, x [I + 12], 7, 1804603682); d = ff (d, a, B, c, x [I + 13], 12,-40341101 ); c = ff (c, d, a, B, x [I + 14], 17,- 1502002290); B = ff (B, c, d,, x [I + 15], 22,123 6582429); a = gg (a, B, c, d, x [I + 1], 5,-165796510 ); d = gg (d, a, B, c, x [I + 6], 9,-1069501632); c = gg (c, d, a, B, x [I + 11], 14,643 717713); B = gg (B, c, d, a, x [I + 0], 20,-373897302 ); a = gg (a, B, c, d, x [I + 5], 5,-701558691); d = gg (d, a, B, c, x [I + 10], 9, 38016083); c = gg (c, d, a, B, x [I + 15], 14,-660478335 ); B = gg (B, c, d, a, x [I + 4], 20,-405537848); a = gg (a, B, c, d, x [I + 9], 5, 568446438); d = gg (d, a, B, c, x [I + 14], 9,-1019803690 ); c = gg (c, d, a, B, x [I + 3], 14,-187363961); B = gg (B, c, d,, x [I + 8], 20,116 limit 1501); a = gg (a, B, c, d, x [I + 13], 5,-1444681467 ); d = gg (d, a, B, c, x [I + 2], 9,-51403784); c = gg (c, d, a, B, x [I + 7], 14,173 5328473); B = gg (B, c, d, a, x [I + 12], 20,-1926607734 ); a = hh (a, B, c, d, x [I + 5], 4,-378558); d = hh (d, a, B, c, x [I + 8], 11,-2022574463); c = hh (c, d, a, B, x [I + 11], 16,183 9030133 ); B = hh (B, c, d, a, x [I + 14], 23,-35309556); a = hh (a, B, c, d, x [I + 1], 4,-1530992060); d = hh (d, a, B, c, x [I + 4], 11,127 2893353 ); c = hh (c, d, a, B, x [I + 7], 16,-155497632); B = hh (B, c, d,, x [I + 10], 23,-1094730640); a = hh (a, B, c, d, x [I + 13], 4, 681279174 ); d = hh (d, a, B, c, x [I + 0], 11,-358537222); c = hh (c, d, a, B, x [I + 3], 16,-722521979); B = hh (B, c, d, a, x [I + 6], 23,760 29189 ); a = hh (a, B, c, d, x [I + 9], 4,-640364487); d = hh (d, a, B, c, x [I + 12], 11,-421815835); c = hh (c, d, a, B, x [I + 15], 16,530 742520 ); B = hh (B, c, d, a, x [I + 2], 23,-995338651); a = ii (a, B, c, d, x [I + 0], 6,-198630844); d = ii (d, a, B, c, x [I + 7], 10,112 6891415 ); c = ii (c, d, a, B, x [I + 14], 15,-1416354905); B = ii (B, c, d,, x [I + 5], 21,-57434055); a = ii (a, B, c, d, x [I + 12], 6, 1700485571 ); d = ii (d, a, B, c, x [I + 3], 10,-1894986606); c = ii (c, d, a, B, x [I + 10], 15,-1051523); B = ii (B, c, d, a, x [I + 1], 21,-2054922799 ); a = ii (a, B, c, d, x [I + 8], 6, 1873313359); d = ii (d, a, B, c, x [I + 15], 10,-30611744); c = ii (c, d, a, B, x [I + 6], 15,-1560198380 ); B = ii (B, c, d, a, x [I + 13], 21,130 9151649); a = ii (a, B, c, d, x [I + 4], 6,-145523070); d = ii (d, a, B, c, x [I + 11], 10,-1120210379 ); c = ii (c, d, a, B, x [I + 2], 15,718 787259); B = ii (B, c, d,, x [I + 9], 21,-343485551); a = add (a, olda); B = add (B, oldb); c = add (c, oldc ); d = add (d, oldd);} return rhex (a) + rhex (B) + rhex (c) + rhex (d );} alert (MD5 ("admin"); script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.