Advertisement
HJin_me

help for js

Dec 26th, 2011
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 8.61 KB | None | 0 0
  1. <!doctype html>
  2. <!--
  3. MD5calc in HTML and Javascript
  4. version alpha 5
  5.  
  6. Written by @chenxiaoqino @HJin_me, 2011-10-19
  7. Based on js MD5 Lib
  8. Published under New BSD license: http://www.opensource.org/licenses/bsd-license.php
  9. * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  10. *   Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  11. *   Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  12. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13. -->
  14. <html>
  15. <head>
  16. <meta charset="UTF-8" />
  17. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  18. <title>md5 password creator</title>
  19. <style>
  20. body {line-height:150%;}
  21. div {padding:10px;}
  22. span {background:rgb(255,255,190);}
  23. div#resultbox span {font-family:monospace;}
  24. #recreatebox {display:none;}
  25. </style>
  26. <script>
  27. /*
  28.  * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
  29.  * Digest Algorithm, as defined in RFC 1321.
  30.  * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
  31.  * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  32.  * Distributed under the BSD License
  33.  * See http://pajhome.org.uk/crypt/md5 for more info.
  34.  
  35.  Modified and compressed by @chenxiaoqino
  36.  */
  37. function md5(a){function b(a){return d(c(e(a)))}function c(a){return g(h(f(a),a.length*8))}function d(a){var b="0123456789abcdef",c="",d;for(var e=0;e<a.length;e++)d=a.charCodeAt(e),c+=b.charAt(d>>>4&15)+b.charAt(d&15);return c}function e(a){var b="",c=-1,d,e;while(++c<a.length)d=a.charCodeAt(c),e=c+1<a.length?a.charCodeAt(c+1):0,55296<=d&&d<=56319&&56320<=e&&e<=57343&&(d=65536+((d&1023)<<10)+(e&1023),c++),d<=127?b+=String.fromCharCode(d):d<=2047?b+=String.fromCharCode(192|d>>>6&31,128|d&63):d<=65535?b+=String.fromCharCode(224|d>>>12&15,128|d>>>6&63,128|d&63):d<=2097151&&(b+=String.fromCharCode(240|d>>>18&7,128|d>>>12&63,128|d>>>6&63,128|d&63));return b}function f(a){var b=Array(a.length>>2);for(var c=0;c<b.length;c++)b[c]=0;for(var c=0;c<a.length*8;c+=8)b[c>>5]|=(a.charCodeAt(c/8)&255)<<c%32;return b}function g(a){var b="";for(var c=0;c<a.length*32;c+=8)b+=String.fromCharCode(a[c>>5]>>>c%32&255);return b}function h(a,b){a[b>>5]|=128<<b%32,a[(b+64>>>9<<4)+14]=b;var c=1732584193,d=-271733879,e=-1732584194,f=271733878;for(var g=0;g<a.length;g+=16){var h=c,i=d,o=e,p=f;c=j(c,d,e,f,a[g+0],7,-680876936),f=j(f,c,d,e,a[g+1],12,-389564586),e=j(e,f,c,d,a[g+2],17,606105819),d=j(d,e,f,c,a[g+3],22,-1044525330),c=j(c,d,e,f,a[g+4],7,-176418897),f=j(f,c,d,e,a[g+5],12,1200080426),e=j(e,f,c,d,a[g+6],17,-1473231341),d=j(d,e,f,c,a[g+7],22,-45705983),c=j(c,d,e,f,a[g+8],7,1770035416),f=j(f,c,d,e,a[g+9],12,-1958414417),e=j(e,f,c,d,a[g+10],17,-42063),d=j(d,e,f,c,a[g+11],22,-1990404162),c=j(c,d,e,f,a[g+12],7,1804603682),f=j(f,c,d,e,a[g+13],12,-40341101),e=j(e,f,c,d,a[g+14],17,-1502002290),d=j(d,e,f,c,a[g+15],22,1236535329),c=k(c,d,e,f,a[g+1],5,-165796510),f=k(f,c,d,e,a[g+6],9,-1069501632),e=k(e,f,c,d,a[g+11],14,643717713),d=k(d,e,f,c,a[g+0],20,-373897302),c=k(c,d,e,f,a[g+5],5,-701558691),f=k(f,c,d,e,a[g+10],9,38016083),e=k(e,f,c,d,a[g+15],14,-660478335),d=k(d,e,f,c,a[g+4],20,-405537848),c=k(c,d,e,f,a[g+9],5,568446438),f=k(f,c,d,e,a[g+14],9,-1019803690),e=k(e,f,c,d,a[g+3],14,-187363961),d=k(d,e,f,c,a[g+8],20,1163531501),c=k(c,d,e,f,a[g+13],5,-1444681467),f=k(f,c,d,e,a[g+2],9,-51403784),e=k(e,f,c,d,a[g+7],14,1735328473),d=k(d,e,f,c,a[g+12],20,-1926607734),c=l(c,d,e,f,a[g+5],4,-378558),f=l(f,c,d,e,a[g+8],11,-2022574463),e=l(e,f,c,d,a[g+11],16,1839030562),d=l(d,e,f,c,a[g+14],23,-35309556),c=l(c,d,e,f,a[g+1],4,-1530992060),f=l(f,c,d,e,a[g+4],11,1272893353),e=l(e,f,c,d,a[g+7],16,-155497632),d=l(d,e,f,c,a[g+10],23,-1094730640),c=l(c,d,e,f,a[g+13],4,681279174),f=l(f,c,d,e,a[g+0],11,-358537222),e=l(e,f,c,d,a[g+3],16,-722521979),d=l(d,e,f,c,a[g+6],23,76029189),c=l(c,d,e,f,a[g+9],4,-640364487),f=l(f,c,d,e,a[g+12],11,-421815835),e=l(e,f,c,d,a[g+15],16,530742520),d=l(d,e,f,c,a[g+2],23,-995338651),c=m(c,d,e,f,a[g+0],6,-198630844),f=m(f,c,d,e,a[g+7],10,1126891415),e=m(e,f,c,d,a[g+14],15,-1416354905),d=m(d,e,f,c,a[g+5],21,-57434055),c=m(c,d,e,f,a[g+12],6,1700485571),f=m(f,c,d,e,a[g+3],10,-1894986606),e=m(e,f,c,d,a[g+10],15,-1051523),d=m(d,e,f,c,a[g+1],21,-2054922799),c=m(c,d,e,f,a[g+8],6,1873313359),f=m(f,c,d,e,a[g+15],10,-30611744),e=m(e,f,c,d,a[g+6],15,-1560198380),d=m(d,e,f,c,a[g+13],21,1309151649),c=m(c,d,e,f,a[g+4],6,-145523070),f=m(f,c,d,e,a[g+11],10,-1120210379),e=m(e,f,c,d,a[g+2],15,718787259),d=m(d,e,f,c,a[g+9],21,-343485551),c=n(c,h),d=n(d,i),e=n(e,o),f=n(f,p)}return Array(c,d,e,f)}function i(a,b,c,d,e,f){return n(o(n(n(b,a),n(d,f)),e),c)}function j(a,b,c,d,e,f,g){return i(b&c|~b&d,a,b,e,f,g)}function k(a,b,c,d,e,f,g){return i(b&d|c&~d,a,b,e,f,g)}function l(a,b,c,d,e,f,g){return i(b^c^d,a,b,e,f,g)}function m(a,b,c,d,e,f,g){return i(c^(b|~d),a,b,e,f,g)}function n(a,b){var c=(a&65535)+(b&65535),d=(a>>16)+(b>>16)+(c>>16);return d<<16|c&65535}function o(a,b){return a<<b|a>>>32-b}return b(a);var p}
  38. /*
  39. a simple Hex string to Decimal Big Integer String function
  40. Written by @chenxiaoqino
  41. Published under New BSD license
  42. */
  43. function hex2dec(a){var b=new Array,c,d="";a=d+a,l=a.length;var e=Math.ceil(l*1.21);for(i=0;i<e;i++)b[i]=0;for(i=0;i<l;i++){c=a.charCodeAt(i),c-=48,c>32&&(c-=32),c>9&&(c-=7);for(j=0;j<e;j++)b[j]*=16;b[0]+=c;for(j=0;j<e;j++)while(b[j]>=10)b[j]-=10,b[j+1]+=1}while(b[--e]==0);while(e>=0)d+=String.fromCharCode(b[e--]+48);return d==""&&(d="0"),d}
  44. </script>
  45. <script>
  46. function $(id) {return document.getElementById(id);}
  47. function createPwd()
  48. {
  49.     var salt="";//add your own salt
  50.     for(var i = 0; i < document.form.web.length; i++) {
  51.         if(document.form.web[i].checked && document.form.web[i].value != "none") {
  52.             $("srcbox2").value = document.form.web[i].value;
  53.         }
  54.     }
  55.     var rawString = md5($("srcbox1").value || '')
  56.             + md5(salt)
  57.             + md5($("srcbox2").value || '')
  58.             + md5($("version").value || '');
  59.    
  60.     var str_md5 = md5(rawString);
  61.     var str_decimal = hex2dec(str_md5);
  62.     var length = parseInt($("cutselect").value) || str_decimal.length;
  63.  
  64.     var boxhex=$("hexresult");
  65.     boxhex.innerHTML=str_md5.substr(0,length);
  66.     var boxdec=$("decresult");
  67.     boxdec.innerHTML=str_decimal.substr(0,6);
  68.     return false;
  69. }
  70. </script>
  71. </head>
  72. <body>
  73.     <form action="#" onsubmit="return createPwd();" name="form">
  74.             输入主密码:
  75.             <input type="password" id="srcbox1"/>
  76.             <br>
  77.             输入网站名:
  78.             <input type="text" id="srcbox2"/>
  79.             <br>
  80.             <input type="radio" id="gmail" name="web" value="gmail"><label for="gmail">gmail</label>
  81.             <input type="radio" id="msn" name="web" value="msn"><label for="msn">msn</label>
  82.             <input type="radio" id="taobao" name="web" value="taobao"><label for="taobao">taobao</label>
  83.             <input type="radio" id="none" name="web" value="none"><label for="none">input</label>
  84.             <br />
  85.             密码版本   :
  86.             <select id="version" >
  87.                 <option value="2012spring">2012春</option>
  88.                 <option value="2012summer">2012夏</option>
  89.                 <option value="2012autum">2012秋</option>
  90.                 <option value="2012winter">2012冬</option>
  91.             </select>
  92.             <br>
  93.             密码长度   :
  94.             <select id="cutselect" onchange="cut();" >  
  95.                 <option value="20" selected >20位</option>
  96.                 <option value="32">32位</option>
  97.                     <option value="16" >16位</option>
  98.                     <option value="12" >12位</option>
  99.                     <option value="10" >10位</option>
  100.                     <option value="8" >8位</option>
  101.                 <option value="6" >6位</option>
  102.             </select>
  103.             <br>
  104.                 <input type="submit" id="submit" value="计算密码"/>
  105.    
  106.     </form>
  107.     字符密码:
  108.     <textarea id="hexresult" onFocus=this.select() onMouseOver=this.focus() rows="1" ></textarea>
  109.     <br>
  110.     数字密码:
  111.     <textarea id="decresult" onFocus=this.select() onMouseOver=this.focus() rows="1" ></textarea>
  112.  
  113. </body>
  114. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement