index.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <!-- saved from url=(0014)about:internet -->
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
  4. <head>
  5. <title>crypty</title>
  6. <script src="/js/jquery-1.7.2.js"></script>
  7. <script src="/js/aes.js"></script>
  8. <script src="/js/tripledes.js"></script>
  9. <script src="/js/rabbit.js"></script>
  10. <script src="/js/rc4.js"></script>
  11. </head>
  12. <body>
  13. <div>
  14. <div>plain:</div>
  15. <textarea rows="10" cols="64" name="message" id="msg_source" class="text_source"></textarea>
  16. <div>
  17. <p>algorithm:</p>
  18. <ul>
  19. <input type="radio" name="Etype" value="aes" checked="checked" />AES
  20. <input type="radio" name="Etype" value="des" />DES
  21. <input type="radio" name="Etype" value="rc4" />RC4
  22. <input type="radio" name="Etype" value="rabbit" />Rabbit
  23. <input type="radio" name="Etype" value="tripledes" />TripleDes
  24. </ul>
  25. </div>
  26. <div class="OptDetail Button">
  27. <p class="input">pass:
  28. <input type="text" id="pwd" />
  29. </p>
  30. <ul>
  31. <button onclick="encrypt();">encrypt</button>
  32. <button onclick="decrypt();">decrypt</button>
  33. </ul>
  34. </div>
  35. <div>encrypted:</div>
  36. <textarea rows="10" cols="64" name="cipher" id="encrypt_result" onclick="this.select();"></textarea>
  37. <script>
  38. function encrypt() {
  39. switch ($('input[name="Etype"]:checked').val()) {
  40. case "aes":
  41. $("#encrypt_result").val(CryptoJS.AES.encrypt($("#msg_source").val(), $("#pwd").val()));
  42. break;
  43. case "des":
  44. $("#encrypt_result").val(CryptoJS.DES.encrypt($("#msg_source").val(), $("#pwd").val()));
  45. break;
  46. case "rabbit":
  47. $("#encrypt_result").val(CryptoJS.Rabbit.encrypt($("#msg_source").val(), $("#pwd").val()));
  48. break;
  49. case "rc4":
  50. $("#encrypt_result").val(CryptoJS.RC4.encrypt($("#msg_source").val(), $("#pwd").val()));
  51. break;
  52. case "tripledes":
  53. $("#encrypt_result").val(CryptoJS.TripleDES.encrypt($("#msg_source").val(), $("#pwd").val()));
  54. break;
  55. }
  56. }
  57. function decrypt() {
  58. switch ($('input[name="Etype"]:checked').val()) {
  59. case "aes":
  60. $("#msg_source").val(CryptoJS.AES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  61. break;
  62. case "des":
  63. $("#msg_source").val(CryptoJS.DES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  64. break;
  65. case "rabbit":
  66. $("#msg_source").val(CryptoJS.Rabbit.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  67. break;
  68. case "rc4":
  69. $("#msg_source").val(CryptoJS.RC4.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  70. break;
  71. case "tripledes":
  72. $("#msg_source").val(CryptoJS.TripleDES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  73. break;
  74. }
  75. }
  76. </script>
  77. </div>
  78. </body>
  79. </html>