index.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  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. <link rel="stylesheet" href="/css/bootstrap.min.css" crossorigin="anonymous">
  12. <link rel="preconnect" href="https://fonts.gstatic.com">
  13. <link href="https://fonts.loli.net/css2?family=Anonymous+Pro:ital,wght@0,400;0,700;1,400;1,700
  14. &family=Noto+Serif+SC:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  15. <link rel="stylesheet" href="/css/style.css">
  16. <style>
  17. .sel:hover {
  18. background-color: rgb(220, 220, 220);
  19. cursor: pointer;
  20. }
  21. .sel input:hover {
  22. cursor: pointer;
  23. }
  24. </style>
  25. </head>
  26. <body>
  27. <a class="btn btn-info" href="/"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp;返回</a>
  28. <div>
  29. <div class="row">
  30. <div class="col-lg-6 col-md-6 col-xs-12">
  31. 明文:
  32. <textarea class="col-xs-12" rows="10" name="message" id="msg_source" class="text_source"></textarea>
  33. </div>
  34. </div>
  35. <div class="row" style="padding:5px">
  36. <div class="col-lg-6 col-md-6 col-xs-12">
  37. <div class="input-group" style="margin:5px">
  38. <span class="input-group-addon">加密算法</span>
  39. <span class="input-group-addon sel" value="aes"><input type="radio" name="Etype" value="aes"
  40. checked="checked" />AES</span>
  41. <span class="input-group-addon sel" value="des"><input type="radio" name="Etype"
  42. value="des" />DES</span>
  43. <span class="input-group-addon sel" value="rc4"><input type="radio" name="Etype"
  44. value="rc4" />RC4</span>
  45. <span class="input-group-addon sel" value="rabbit"><input type="radio" name="Etype"
  46. value="rabbit" />Rabbit</span>
  47. <span class="input-group-addon sel" value="tripledes"><input type="radio" name="Etype"
  48. value="tripledes" />TripleDes</span>
  49. </div>
  50. <div class="input-group" style="margin:5px">
  51. <span class="input-group-addon">密码</span>
  52. <input type="text" class="form-control" id="pwd" />
  53. </p>
  54. <span class="input-group-btn">
  55. <button class="btn btn-default" onclick="encrypt();"
  56. style="text-shadow: rgb(185, 185, 185) 3px 2px 4px;"><span
  57. class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span>&nbsp;加密</button>
  58. <button class="btn btn-default" onclick="decrypt();"
  59. style="text-shadow: rgb(185, 185, 185) 3px 2px 4px;"><span
  60. class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>&nbsp;解密</button>
  61. </span>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="row">
  66. <div class="col-lg-6 col-md-6 col-xs-12">
  67. <div>密文:</div>
  68. <textarea rows="10" class="col-xs-12" name="cipher" id="encrypt_result"
  69. onclick="this.select();"></textarea>
  70. </div>
  71. </div>
  72. <script>
  73. $('span').on("click", function () {
  74. $('input[value="' + $(this).attr('value') + '"]').attr('checked', 'checked')
  75. })
  76. function encrypt() {
  77. switch ($('input[name="Etype"]:checked').val()) {
  78. case "aes":
  79. $("#encrypt_result").val(CryptoJS.AES.encrypt($("#msg_source").val(), $("#pwd").val()));
  80. break;
  81. case "des":
  82. $("#encrypt_result").val(CryptoJS.DES.encrypt($("#msg_source").val(), $("#pwd").val()));
  83. break;
  84. case "rabbit":
  85. $("#encrypt_result").val(CryptoJS.Rabbit.encrypt($("#msg_source").val(), $("#pwd").val()));
  86. break;
  87. case "rc4":
  88. $("#encrypt_result").val(CryptoJS.RC4.encrypt($("#msg_source").val(), $("#pwd").val()));
  89. break;
  90. case "tripledes":
  91. $("#encrypt_result").val(CryptoJS.TripleDES.encrypt($("#msg_source").val(), $("#pwd").val()));
  92. break;
  93. }
  94. }
  95. function decrypt() {
  96. switch ($('input[name="Etype"]:checked').val()) {
  97. case "aes":
  98. $("#msg_source").val(CryptoJS.AES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  99. break;
  100. case "des":
  101. $("#msg_source").val(CryptoJS.DES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  102. break;
  103. case "rabbit":
  104. $("#msg_source").val(CryptoJS.Rabbit.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  105. break;
  106. case "rc4":
  107. $("#msg_source").val(CryptoJS.RC4.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  108. break;
  109. case "tripledes":
  110. $("#msg_source").val(CryptoJS.TripleDES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  111. break;
  112. }
  113. }
  114. </script>
  115. </div>
  116. </body>
  117. </html>