index.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <head>
  2. <meta charset="UTF-8">
  3. <title>crypty</title>
  4. <script src="../js/jquery-1.7.2.js"></script>
  5. <script src="../js/aes.js"></script>
  6. <script src="../js/pad-pkcs7.js"></script>
  7. <script src="../js/mode-ecb.js"></script>
  8. <!-- <link async rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
  9. integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"> -->
  10. <link rel="stylesheet" href="../css/bootstrap.min.css" crossorigin="anonymous">
  11. <link rel="preconnect" href="https://fonts.gstatic.com">
  12. <link href="https://fonts.loli.net/css2?family=Anonymous+Pro:ital,wght@0,400;0,700;1,400;1,700
  13. &family=Noto+Serif+SC:wght@300;400;500;600;700&display=swap" rel="stylesheet">
  14. <link rel="stylesheet" href="../css/style.css">
  15. <style>
  16. .sel:hover {
  17. background-color: rgb(220, 220, 220);
  18. cursor: pointer;
  19. }
  20. .sel input:hover {
  21. cursor: pointer;
  22. }
  23. textarea {
  24. outline: none;
  25. border: 4px double grey;
  26. border-radius: 5px;
  27. }
  28. </style>
  29. <script>
  30. const key = CryptoJS.enc.Utf8.parse("abcdefgabcdefg12");
  31. function aesDecrypt(encrypted) {
  32. var cipherParams = CryptoJS.lib.CipherParams.create({ ciphertext: CryptoJS.enc.Hex.parse(encrypted) })
  33. var decrypted = CryptoJS.AES.decrypt(cipherParams, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 });
  34. return decrypted.toString(CryptoJS.enc.Utf8);
  35. }
  36. function aesEncrypt(encrypted) {
  37. return CryptoJS.AES.encrypt(encrypted, key, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }).ciphertext.toString();
  38. }
  39. $().ready(e => {
  40. $("#dec").val('aes~~~\nuses pad-pkcs7, ecb\nkey=abcdefgabcdefg12')
  41. $('#enc').val(aesEncrypt($("#dec").val()))
  42. })
  43. </script>
  44. </head>
  45. <body>
  46. <a class="btn btn-info" href="/"><span class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp;返回</a>
  47. <div>
  48. <div class="row">
  49. <div class="col-lg-6 col-md-6 col-xs-12">
  50. 明文:
  51. <textarea class="col-xs-12" rows="10" name="message" id="dec" class="text_source"
  52. onclick="this.select();" style="resize:vertical"
  53. oninput="$('#enc').val(aesEncrypt($(this).val()))"></textarea>
  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="enc" onclick="this.select();"
  60. style="resize:vertical" oninput="$('#dec').val(aesDecrypt($(this).val()))"></textarea>
  61. </div>
  62. </div>
  63. </div>
  64. </body>
  65. </html>