index.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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="/" style="text-shadow: rgb(85, 85, 85) 3px 2px 4px;"><span
  47. class="glyphicon glyphicon-home" aria-hidden="true"></span>&nbsp;返回</a>
  48. <div>
  49. <div class="row">
  50. <div class="col-lg-6 col-md-6 col-xs-12">
  51. 明文:
  52. <textarea class="col-xs-12" rows="10" name="message" id="dec" class="text_source"
  53. onclick="this.select();" style="resize:vertical"
  54. oninput="$('#enc').val(aesEncrypt($(this).val()))"></textarea>
  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="enc" onclick="this.select();"
  61. style="resize:vertical" oninput="$('#dec').val(aesDecrypt($(this).val()))"></textarea>
  62. </div>
  63. </div>
  64. </div>
  65. </body>
  66. </html>