index.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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" checked="checked" />AES</span>
  40. <span class="input-group-addon sel" value="des"><input type="radio" name="Etype" value="des" />DES</span>
  41. <span class="input-group-addon sel" value="rc4"><input type="radio" name="Etype" value="rc4" />RC4</span>
  42. <span class="input-group-addon sel" value="rabbit"><input type="radio" name="Etype" value="rabbit" />Rabbit</span>
  43. <span class="input-group-addon sel" value="tripledes"><input type="radio" name="Etype" value="tripledes" />TripleDes</span>
  44. </div>
  45. <div class="input-group" style="margin:5px">
  46. <span class="input-group-addon">密码</span>
  47. <input type="text" class="form-control" id="pwd" />
  48. </p>
  49. <span class="input-group-btn">
  50. <button class="btn btn-default" onclick="encrypt();" style="text-shadow: rgb(185, 185, 185) 3px 2px 4px;"><span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span>&nbsp;加密</button>
  51. <button class="btn btn-default" onclick="decrypt();" style="text-shadow: rgb(185, 185, 185) 3px 2px 4px;"><span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>&nbsp;解密</button>
  52. </span>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="row">
  57. <div class="col-lg-6 col-md-6 col-xs-12">
  58. <div>密文:</div>
  59. <textarea rows="10" class="col-xs-12" name="cipher" id="encrypt_result" onclick="this.select();"></textarea>
  60. </div>
  61. </div>
  62. <script>
  63. $('span').on("click", function () {
  64. $('input[value="' + $(this).attr('value') + '"]').attr('checked', 'checked')
  65. })
  66. function encrypt() {
  67. switch ($('input[name="Etype"]:checked').val()) {
  68. case "aes":
  69. $("#encrypt_result").val(CryptoJS.AES.encrypt($("#msg_source").val(), $("#pwd").val()));
  70. break;
  71. case "des":
  72. $("#encrypt_result").val(CryptoJS.DES.encrypt($("#msg_source").val(), $("#pwd").val()));
  73. break;
  74. case "rabbit":
  75. $("#encrypt_result").val(CryptoJS.Rabbit.encrypt($("#msg_source").val(), $("#pwd").val()));
  76. break;
  77. case "rc4":
  78. $("#encrypt_result").val(CryptoJS.RC4.encrypt($("#msg_source").val(), $("#pwd").val()));
  79. break;
  80. case "tripledes":
  81. $("#encrypt_result").val(CryptoJS.TripleDES.encrypt($("#msg_source").val(), $("#pwd").val()));
  82. break;
  83. }
  84. }
  85. function decrypt() {
  86. switch ($('input[name="Etype"]:checked').val()) {
  87. case "aes":
  88. $("#msg_source").val(CryptoJS.AES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  89. break;
  90. case "des":
  91. $("#msg_source").val(CryptoJS.DES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  92. break;
  93. case "rabbit":
  94. $("#msg_source").val(CryptoJS.Rabbit.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  95. break;
  96. case "rc4":
  97. $("#msg_source").val(CryptoJS.RC4.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  98. break;
  99. case "tripledes":
  100. $("#msg_source").val(CryptoJS.TripleDES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  101. break;
  102. }
  103. }
  104. </script>
  105. </div>
  106. </body>