kone
소미소프트
소미소프트

개인용 base64 해독 사이트 개조

유틸
21,257 views · 10 points

원글

https://kone.gg/s/somisoft/aDrPS5pBfLM0b8XyWYG58b

위에서 받아서 잘 쓰고있다가 ai 사용해서 편의성 개선 했습니다.

1

변경한거

-해독하기 버튼 삭제 (자동해독이라 필요 없었음)

-붙여넣기 버튼 추가 (정책상 허용버튼 눌러야해서 필요 없을지도)

-출력된 링크 새탭 열기버튼

-줄마다 개별 해독 (한글이 포함된 줄은 그대로 출력)

-자동 2회해독 (1회 후 링크가 아닐경우 한번 더)

-다크모드 (모드 상태 저장)

수정

-작가명등을 위해 2회 해독 후에도 링크가 아닐경우 1회 해독 결과를 출력할 수 있도록 하였습니다.

복붙할 때 줄넘김 생기면서 작동 안해서 따로 업로드 했습니다.

aHR0cHM6Ly9raW8uYWMvYy9iZFVuMjZ4bjFJSEoxNVlkNzhjQWVi

무제한 / 비번없음

사용방법

메모장에 아래 내용 복붙 후 확장자명을 .txt에서 .html로 변경

<!DOCTYPE html>

<html lang="ko">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Base64 자동 디코더</title>

<style>

* { box-sizing: border-box; margin: 0; padding: 0; }

body {

font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

background-color: #f4f6f9;

color: #212529;

display: flex; justify-content: center; align-items: center;

min-height: 100vh; padding: 20px;

transition: background-color 0.3s, color 0.3s;

}

body.dark {

background-color: #121212;

color: #e9ecef;

}

.container {

background: #ffffff; padding: 30px; border-radius: 12px;

box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);

width: 100%; max-width: 600px;

transition: background-color 0.3s, color 0.3s;

}

body.dark .container {

background: #1e1e1e;

color: #e9ecef;

}

h2 { margin-bottom: 20px; text-align: center; }

.input-group { margin-bottom: 20px; }

label { display: block; margin-bottom: 8px; font-weight: bold; }

textarea {

width: 100%; height: 100px; padding: 12px;

border: 1px solid #ccc; border-radius: 6px;

font-size: 14px; resize: vertical; outline: none;

transition: background-color 0.3s, color 0.3s;

}

textarea:focus { border-color: #007bff; }

body.dark textarea {

background-color: #2c2c2c;

color: #e9ecef;

border: 1px solid #555;

}

.btn-group { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

button {

flex: 1; padding: 12px; background-color: #007bff; color: white;

border: none; border-radius: 6px; font-size: 16px;

cursor: pointer; transition: background-color 0.2s;

}

button:hover { background-color: #0056b3; }

button.reset-btn { background-color: #6c757d; }

button.reset-btn:hover { background-color: #5a6268; }

.result-box {

background-color: #e9ecef; padding: 15px; border-radius: 6px;

min-height: 60px; word-break: break-all;

font-family: monospace; font-size: 15px;

transition: background-color 0.3s, color 0.3s;

}

body.dark .result-box {

background-color: #2c2c2c;

color: #e9ecef;

}

.line { margin-bottom: 8px; }

.line button { margin-left: 10px; flex: none; padding: 4px 8px; font-size: 12px; }

/* 두 번 해독됨 표시 스타일 */

.decoded-note {

font-size: 0.7em;

color: #6c757d;

margin-left: 8px;

}

/* 다크모드 버튼 박스 스타일 */

.dark-toggle {

position: fixed;

top: 20px;

right: 20px;

background-color: #343a40;

color: white;

padding: 12px;

border: none;

border-radius: 8px;

cursor: pointer;

font-size: 20px;

box-shadow: 0 2px 6px rgba(0,0,0,0.3);

}

.dark-toggle:hover {

background-color: #23272b;

}

</style>

</head>

<body>

<!-- 오른쪽 상단 다크모드 버튼 -->

<button id="darkToggleBtn" class="dark-toggle" onclick="toggleDarkMode()">🌙</button>

<div class="container">

<h2>Base64 자동 디코더</h2>

<div class="input-group">

<label for="encodedInput">Base64 문자열 입력</label>

<textarea id="encodedInput" placeholder="여기에 Base64 문자열을 붙여넣으세요..."></textarea>

</div>

<div class="btn-group">

<button id="pasteBtn">📋 붙여넣기</button>

<button class="reset-btn" onclick="resetForm()">초기화</button>

</div>

<div class="input-group">

<label>디코딩 결과</label>

<div id="resultOutput" class="result-box">결과가 여기에 표시됩니다.</div>

</div>

</div>

<script>

function decodeBase64Utf8(str) {

try {

const cleanStr = str.trim();

if (!cleanStr) return "";

const binaryString = atob(cleanStr);

const bytes = new Uint8Array(binaryString.length);

for (let i = 0; i < binaryString.length; i++) {

bytes[i] = binaryString.charCodeAt(i);

}

return new TextDecoder().decode(bytes);

} catch (e) {

return str;

}

}

function containsKorean(text) {

return /[가-힣]/.test(text);

}

function decodeLines(inputText) {

const lines = inputText.split("\n").filter(l => l.trim() !== "");

const resultBox = document.getElementById('resultOutput');

resultBox.innerHTML = "";

let lineNumber = 1;

lines.forEach((line) => {

let decoded = line.trim();

let doubleDecoded = false;

let firstDecoded = null;

if (!decoded) return;

if (!containsKorean(decoded)) {

firstDecoded = decodeBase64Utf8(decoded); // 1회 해독 결과 저장

decoded = firstDecoded;

if (!/^https?:\/\/[^\s]+$/.test(decoded)) {

let secondTry = decodeBase64Utf8(decoded);

if (/^https?:\/\/[^\s]+$/.test(secondTry)) {

decoded = secondTry;

doubleDecoded = true;

} else if (!containsKorean(secondTry)) {

decoded = "❌ 링크가 아니거나 올바른 Base64 형식이 아닙니다.";

// 추가 결과 박스 생성 (1회 해독 결과 표시, 일반 폰트 스타일)

const extraDiv = document.createElement("div");

extraDiv.className = "line";

extraDiv.textContent = 1회 해독 결과: ${firstDecoded};

resultBox.appendChild(extraDiv);

} else {

decoded = secondTry;

}

}

}

const lineDiv = document.createElement("div");

lineDiv.className = "line";

// 여러 줄일 때 번호 붙이기, 단 한글 포함된 줄은 번호 제외

if (lines.length > 1 && !containsKorean(decoded)) {

lineDiv.textContent = ${lineNumber}. ${decoded};

lineNumber++;

} else {

lineDiv.textContent = decoded;

}

if (/^https?:\/\/[^\s]+/.test(decoded)) {

const btn = document.createElement("button");

btn.textContent = "🔗";

btn.onclick = () => window.open(decoded, "_blank");

lineDiv.appendChild(btn);

if (doubleDecoded) {

const note = document.createElement("span");

note.className = "decoded-note";

note.textContent = "두 번 해독됨";

lineDiv.appendChild(note);

}

}

resultBox.appendChild(lineDiv);

});

}

function resetForm() {

document.getElementById('encodedInput').value = '';

document.getElementById('resultOutput').innerText = '결과가 여기에 표시됩니다.';

}

document.getElementById('encodedInput').addEventListener('input', () => {

const input = document.getElementById('encodedInput').value;

if (!input.trim()) {

document.getElementById('resultOutput').innerText = "문자열을 입력해 주세요.";

return;

}

decodeLines(input);

});

document.getElementById('pasteBtn').addEventListener('click', async () => {

try {

const text = await navigator.clipboard.readText();

document.getElementById('encodedInput').value = text;

decodeLines(text);

} catch (err) {

alert("클립보드에서 붙여넣기를 할 수 없습니다. 브라우저 권한을 확인하세요.");

}

});

// 다크모드 토글 + 저장

function toggleDarkMode() {

document.body.classList.toggle("dark");

const btn = document.getElementById("darkToggleBtn");

if (document.body.classList.contains("dark")) {

localStorage.setItem("theme", "dark");

btn.textContent = "☀️";

} else {

localStorage.setItem("theme", "light");

btn.textContent = "🌙";

}

}

// 페이지 로드 시 저장된 값 불러오기

window.addEventListener("DOMContentLoaded", () => {

const savedTheme = localStorage.getItem("theme");

const btn = document.getElementById("darkToggleBtn");

if (savedTheme === "dark") {

document.body.classList.add("dark");

btn.textContent = "☀️";

} else {

btn.textContent = "🌙";

}

});

</script>

</body>

</html>

문제시 삭제하겠습니다.

10
3 comments
어따쓰지 귀차니즘병환자들을위한건가
이젠 이 판도 고여버린거지 아주 조금 더 편해질라고 하는거야
All
Title
Body