index.html 2.3 KB

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