MD5 encryption for JavaScript

Source: Internet
Author: User
Tags crypt md5 encryption

1. First to download the JS file to http://pajhome.org.uk/crypt/md5/.

2. In the page file, add:

<script type= "Text/javascript" src= "Md5.js" ></script>

3. Use function Hex_md5 () for encryption, for example:

Frm.pwd.value =hex_md5 (Frm.pwd.value);

Examples of Use:

HTML code
  1. <html>
  2. <head>
  3. <script type="Text/javascript" src="Md5.js"></script>
  4. <script>
  5. function MD5 () {
  6. var hash=hex_md5 (document.getElementById ("text"). value);
  7. document.getElementById ("result"). value=Hash;
  8. }
  9. function trans () {
  10. Frm.pwd.value =hex_md5 (frm.pwd.value);
  11. document.getElementById ("Result2"). value=Frm.pwd.value;
  12. }
  13. function Submit () {
  14. Default commit processing, custom commit pre-processing method do not use submit as function name
  15. }
  16. onsubmit="Pwd.value =hex_md5 (pwd.value)"
  17. </Script>
  18. </head>
  19. <body>
  20. http://pajhome.org.uk/crypt/md5/<br>
  21. MD5 encryption:<br>
  22. before conversion: <input type=" text " id=" text " style=" width:300 " value=" Hello world "/><br>  
  23. Converted:<input type="text" id="result" style="width:300"/><BR >
  24. <input type="button" value="test" onclick="MD5 ()"/>
  25. <br>
  26. <form name="frm" >
  27. Name:<input type="text" id="name" /><br>
  28. Password:<input type="password" id="pwd"/><br>
  29. <input type="button" value="Submit" onclick="trans ()" /><BR >
  30. Encrypted password:<input type="text" id="result2" style="width:300"/>
  31. </form>
  32. </body>
  33. </html>

from:http://hongan.iteye.com/blog/287044

MD5 encryption for JavaScript

Related Article

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.