index.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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">
  12. <link rel="preconnect" href="https://fonts.googleapis.com">
  13. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  14. <link href="https://fonts.googleapis.com/css2?family=Anonymous+Pro:ital,wght@0,400;0,700;1,400;1,700
  15. &family=Noto+Serif+SC:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  16. <link rel="stylesheet" href="/css/style.css">
  17. <style>
  18. .sel:hover {
  19. background-color: rgb(220, 220, 220);
  20. cursor: pointer;
  21. }
  22. .sel input:hover {
  23. cursor: pointer;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <a class="btn btn-info" href="/"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp;返回</a>
  29. <div>
  30. <div class="row">
  31. <div class="col-lg-6 col-md-6 col-xs-12">
  32. 明文:
  33. <textarea class="col-xs-12" rows="10" name="message" id="msg_source" class="text_source"></textarea>
  34. </div>
  35. </div>
  36. <div class="row" style="padding:5px">
  37. <div class="col-lg-6 col-md-6 col-xs-12">
  38. <div class="input-group" style="margin:5px">
  39. <span class="input-group-addon">加密算法</span>
  40. <span class="input-group-addon sel" value="aes"><input type="radio" name="Etype" value="aes" checked="checked" />AES</span>
  41. <span class="input-group-addon sel" value="des"><input type="radio" name="Etype" value="des" />DES</span>
  42. <span class="input-group-addon sel" value="rc4"><input type="radio" name="Etype" value="rc4" />RC4</span>
  43. <span class="input-group-addon sel" value="rabbit"><input type="radio" name="Etype" value="rabbit" />Rabbit</span>
  44. <span class="input-group-addon sel" value="tripledes"><input type="radio" name="Etype" value="tripledes" />TripleDes</span>
  45. </div>
  46. <div class="input-group" style="margin:5px">
  47. <span class="input-group-addon">密码</span>
  48. <input type="text" class="form-control" id="pwd" />
  49. </p>
  50. <span class="input-group-btn">
  51. <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>
  52. <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>
  53. </span>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="row">
  58. <div class="col-lg-6 col-md-6 col-xs-12">
  59. <div>密文:</div>
  60. <textarea rows="10" class="col-xs-12" name="cipher" id="encrypt_result" onclick="this.select();"></textarea>
  61. </div>
  62. </div>
  63. <script>
  64. $('span').on("click", function () {
  65. $('input[value="' + $(this).attr('value') + '"]').attr('checked', 'checked')
  66. })
  67. function encrypt() {
  68. switch ($('input[name="Etype"]:checked').val()) {
  69. case "aes":
  70. $("#encrypt_result").val(CryptoJS.AES.encrypt($("#msg_source").val(), $("#pwd").val()));
  71. break;
  72. case "des":
  73. $("#encrypt_result").val(CryptoJS.DES.encrypt($("#msg_source").val(), $("#pwd").val()));
  74. break;
  75. case "rabbit":
  76. $("#encrypt_result").val(CryptoJS.Rabbit.encrypt($("#msg_source").val(), $("#pwd").val()));
  77. break;
  78. case "rc4":
  79. $("#encrypt_result").val(CryptoJS.RC4.encrypt($("#msg_source").val(), $("#pwd").val()));
  80. break;
  81. case "tripledes":
  82. $("#encrypt_result").val(CryptoJS.TripleDES.encrypt($("#msg_source").val(), $("#pwd").val()));
  83. break;
  84. }
  85. }
  86. function decrypt() {
  87. switch ($('input[name="Etype"]:checked').val()) {
  88. case "aes":
  89. $("#msg_source").val(CryptoJS.AES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  90. break;
  91. case "des":
  92. $("#msg_source").val(CryptoJS.DES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  93. break;
  94. case "rabbit":
  95. $("#msg_source").val(CryptoJS.Rabbit.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  96. break;
  97. case "rc4":
  98. $("#msg_source").val(CryptoJS.RC4.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  99. break;
  100. case "tripledes":
  101. $("#msg_source").val(CryptoJS.TripleDES.decrypt($("#encrypt_result").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
  102. break;
  103. }
  104. }
  105. </script>
  106. </div>
  107. </body>