antonio_pedro

para teste de elemento

Apr 12th, 2025 (edited)
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <head>
  3. <meta charset="UTF-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  5. <title>JavaScript SEC OBF</title>
  6. <style>
  7. body {
  8. font-family: 'Segoe UI', Arial, sans-serif;
  9. margin: 0;
  10. padding: 20px;
  11. background-color: #2e2e2e;
  12. color: #d0d0d0;
  13. line-height: 1.6;
  14. display: flex;
  15. justify-content: center;
  16. }
  17. .container {
  18. max-width: 800px;
  19. width: 100%;
  20. }
  21. textarea, pre {
  22. width: 100%;
  23. height: 150px;
  24. background-color: #353535;
  25. color: #e0e0e0;
  26. border: 1px solid #505050;
  27. border-radius: 5px;
  28. padding: 10px;
  29. font-family: 'Consolas', monospace;
  30. font-size: 14px;
  31. box-sizing: border-box;
  32. resize: none;
  33. overflow-y: auto;
  34. overflow-x: hidden;
  35. white-space: pre-wrap;
  36. word-break: break-all;
  37. }
  38. button {
  39. margin: 10px 5px;
  40. padding: 10px 20px;
  41. background-color: #b0b0b0;
  42. color: #1a1a1a;
  43. border: none;
  44. border-radius: 5px;
  45. cursor: pointer;
  46. font-weight: 600;
  47. transition: background-color 0.2s;
  48. }
  49. button:hover {
  50. background-color: #c8c8c8;
  51. }
  52. button:disabled {
  53. background-color: #707070;
  54. cursor: not-allowed;
  55. }
  56. h3 {
  57. color: #b0b0b0;
  58. text-align: center;
  59. }
  60. .button-container {
  61. margin: 10px 0;
  62. text-align: center;
  63. }
  64. .copy-btn {
  65. background-color: #909090;
  66. }
  67. .copy-btn:hover {
  68. background-color: #a8a8a8;
  69. }
  70. .notification {
  71. position: fixed;
  72. top: 20px;
  73. right: 20px;
  74. padding: 10px 20px;
  75. background-color: #a6e3a1;
  76. color: #1a1a1a;
  77. border-radius: 5px;
  78. opacity: 0;
  79. transition: opacity 0.3s;
  80. z-index: 1000;
  81. }
  82. .notification.show {
  83. opacity: 1;
  84. }
  85. .notification.error {
  86. background-color: #f2b8b5;
  87. }
  88. </style>
  89. </head>
  90. <body>
  91. <div class="container">
  92. <textarea id="inputCode" placeholder="JS Aqui"></textarea>
  93. <div class="button-container">
  94. <button id="obfuscateBtn">Obfuscar Código</button>
  95. </div>
  96. <h3>Código Ofuscado:</h3>
  97. <pre id="outputCode"></pre>
  98. <div class="button-container">
  99. <button class="copy-btn" onclick="copyCode()">Copiar</button>
  100. </div>
  101. </div>
  102. <script>
  103. const obfuscateBtn = document.getElementById("obfuscateBtn");
  104. const outputElement = document.getElementById("outputCode");
  105.  
  106. obfuscateBtn.addEventListener("click", obfuscateCode);
  107.  
  108. function obfuscateCode() {
  109. let input = document.getElementById("inputCode").value;
  110. if (!input.trim()) {
  111. showNotification("Digite um código JavaScript para ofuscar.", false);
  112. return;
  113. }
  114.  
  115. obfuscateBtn.textContent = "Encriptando código...";
  116. obfuscateBtn.disabled = true;
  117.  
  118. try {
  119. let obfuscatedCode = secureObfuscator(input);
  120. outputElement.textContent = obfuscatedCode;
  121. showNotification("Código ofuscado com sucesso!", true);
  122. } catch (error) {
  123. showNotification("Erro ao ofuscar o código.", false);
  124. console.error("Erro:", error);
  125. } finally {
  126. obfuscateBtn.textContent = "Obfuscar Código";
  127. obfuscateBtn.disabled = false;
  128. }
  129. }
  130.  
  131. function secureObfuscator(code) {
  132. let encoded = btoa(code);
  133. let key = Math.floor(Math.random() * 100) + 1;
  134. let encrypted = '';
  135. for (let i = 0; i < encoded.length; i++) {
  136. encrypted += String.fromCharCode(encoded.charCodeAt(i) ^ key);
  137. }
  138. return `(() => { let d=atob('${btoa(encrypted)}'),k=${key},c='';for(let i=0;i<d.length;i++){c+=String.fromCharCode(d.charCodeAt(i)^k);}eval(atob(c)); })();`;
  139. }
  140.  
  141. function copyCode() {
  142. let code = outputElement.textContent;
  143. if (!code.trim()) {
  144. showNotification("Nenhum código para copiar.", false);
  145. return;
  146. }
  147. navigator.clipboard.writeText(code).then(() => {
  148. showNotification("Código copiado com sucesso!", true);
  149. }).catch(() => {
  150. showNotification("Falha ao copiar o código.", false);
  151. });
  152. }
  153.  
  154. function showNotification(message, isSuccess) {
  155. let notification = document.querySelector(".notification");
  156. if (!notification) {
  157. notification = document.createElement("div");
  158. notification.className = "notification";
  159. document.body.appendChild(notification);
  160. }
  161. notification.textContent = message;
  162. notification.className = `notification ${isSuccess ? "" : "error"} show`;
  163. setTimeout(() => {
  164. notification.classList.remove("show");
  165. }, 3000);
  166. }
  167. </script>
  168. </body>
  169. </html>
Add Comment
Please, Sign In to add comment