/
taesonx
/
practica-decoder
Обзор
Документация
Войти
/
taesonx
/
practica-decoder
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
site/decoder-code.html
238 строк
9 KB
egarinka11
update: decoder-code.html
13 май 2026, 14:44
Верифицирован
13 май 2026, 14:44
e80b477
Код
Авторство
О чём код?
<!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Дешифратор | Исходный код</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: 'Courier New', monospace; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); color: #eee; padding: 2rem; } .container { max-width: 1200px; margin: 0 auto; background: #0d0d1a; padding: 1.5rem; border-radius: 10px; } h1 { color: #e94560; margin-bottom: 1rem; } h2 { color: #ffaa88; margin: 1rem 0 0.5rem 0; font-size: 1.2rem; } .btn-back { display: inline-block; background: #e94560; color: white; padding: 0.5rem 1rem; text-decoration: none; border-radius: 8px; margin-bottom: 1rem; font-family: 'Segoe UI', sans-serif; } .btn-back:hover { background: #ff6b8a; } pre { background: #111; padding: 1rem; border-radius: 8px; overflow-x: auto; font-size: 13px; line-height: 1.4; margin: 1rem 0; } .note { background: rgba(233, 69, 96, 0.2); padding: 0.8rem; border-radius: 8px; margin: 1rem 0; font-family: 'Segoe UI', sans-serif; } footer { text-align: center; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #333; font-family: 'Segoe UI', sans-serif; font-size: 0.8rem; } </style> </head> <body> <div class="container"> <a href="variant.html" class="btn-back">← Назад к вариативной части</a> <h1>📄 Исходный код дешифратора</h1> <div class="note"> <strong>📌 Файл:</strong> Decoder.html<br> <strong>Состав:</strong> HTML + CSS + JavaScript (8 шифров) </div> <h2>🔧 Код (основная логика)</h2> <pre> // ========== ШИФР ЦЕЗАРЯ ========== function caesarCipher() { let text = document.getElementById('caesar-input').value; let shift = parseInt(document.getElementById('caesar-shift').value); let result = ''; for (let i = 0; i < text.length; i++) { let char = text[i]; if (char.match(/[a-zа-я]/i)) { let code = char.charCodeAt(0); let base; if (code >= 65 && code <= 90) base = 65; else if (code >= 97 && code <= 122) base = 97; else if (code >= 1040 && code <= 1071) base = 1040; else base = 1072; result += String.fromCharCode(((code - base + shift) % 26) + base); } else { result += char; } } document.getElementById('caesar-result').innerText = result; } function caesarDecipher() { let text = document.getElementById('caesar-input').value; let shift = parseInt(document.getElementById('caesar-shift').value); let result = ''; for (let i = 0; i < text.length; i++) { let char = text[i]; if (char.match(/[a-zа-я]/i)) { let code = char.charCodeAt(0); let base; if (code >= 65 && code <= 90) base = 65; else if (code >= 97 && code <= 122) base = 97; else if (code >= 1040 && code <= 1071) base = 1040; else base = 1072; let newCode = ((code - base - shift) % 26 + 26) % 26; result += String.fromCharCode(newCode + base); } else { result += char; } } document.getElementById('caesar-result').innerText = result; } // ========== ШИФР АТБАШ ========== function atbashCipher() { let text = document.getElementById('atbash-input').value; let result = ''; for (let i = 0; i < text.length; i++) { let char = text[i]; if (char >= 'A' && char <= 'Z') { result += String.fromCharCode(155 - char.charCodeAt(0)); } else if (char >= 'a' && char <= 'z') { result += String.fromCharCode(219 - char.charCodeAt(0)); } else if (char >= 'А' && char <= 'Я') { result += String.fromCharCode(2127 - char.charCodeAt(0)); } else if (char >= 'а' && char <= 'я') { result += String.fromCharCode(2143 - char.charCodeAt(0)); } else { result += char; } } document.getElementById('atbash-result').innerText = result; } // ========== АЗБУКА МОРЗЕ ========== const morseCode = { 'А': '.-', 'Б': '-...', 'В': '.--', 'Г': '--.', 'Д': '-..', 'Е': '.', 'Ё': '.', 'Ж': '...-', 'З': '--..', 'И': '..', 'Й': '.---', 'К': '-.-', 'Л': '.-..', 'М': '--', 'Н': '-.', 'О': '---', 'П': '.--.', 'Р': '.-.', 'С': '...', 'Т': '-', 'У': '..-', 'Ф': '..-.', 'Х': '....', 'Ц': '-.-.', 'Ч': '---.', 'Ш': '----', 'Щ': '--.-', 'Ъ': '--.--', 'Ы': '-.--', 'Ь': '-..-', 'Э': '..-..', 'Ю': '..--', 'Я': '.-.-', 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..', '0': '-----', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.' }; function textToMorse() { let text = document.getElementById('morse-input').value.toUpperCase(); let result = ''; for (let i = 0; i < text.length; i++) { let char = text[i]; if (morseCode[char]) { result += morseCode[char] + ' '; } else if (char === ' ') { result += ' '; } else { result += char + ' '; } } document.getElementById('morse-result').innerText = result.trim(); } // ========== ШИФР ВИЖЕНЕРА ========== function vigenereCipher() { let text = document.getElementById('vigenere-input').value.toUpperCase(); let key = document.getElementById('vigenere-key').value.toUpperCase(); let result = ''; let keyIndex = 0; for (let i = 0; i < text.length; i++) { let char = text[i]; if (char >= 'A' && char <= 'Z') { let shift = key.charCodeAt(keyIndex % key.length) - 65; let newChar = String.fromCharCode(((char.charCodeAt(0) - 65 + shift) % 26) + 65); result += newChar; keyIndex++; } else { result += char; } } document.getElementById('vigenere-result').innerText = result; } // ========== ШИФР ВЕРНАМА (XOR) ========== function vernamCipher() { let text = document.getElementById('vernam-input').value; let key = document.getElementById('vernam-key').value; let result = ''; for (let i = 0; i < text.length && i < key.length; i++) { result += String.fromCharCode(text.charCodeAt(i) ^ key.charCodeAt(i)); } document.getElementById('vernam-result').innerText = result; } // ========== ШИФР ПОЛИБИЯ ========== const polybiusSquare = { 'А':'11','Б':'12','В':'13','Г':'14','Д':'15','Е':'16', 'Ж':'21','З':'22','И':'23','Й':'24','К':'25','Л':'26', 'М':'31','Н':'32','О':'33','П':'34','Р':'35','С':'36', 'Т':'41','У':'42','Ф':'43','Х':'44','Ц':'45','Ч':'46', 'Ш':'51','Щ':'52','Ъ':'53','Ы':'54','Ь':'55','Э':'56', 'Ю':'61','Я':'62' }; function polybiusCipher() { let text = document.getElementById('polybius-input').value.toUpperCase(); let result = ''; for (let i = 0; i < text.length; i++) { let char = text[i]; if (polybiusSquare[char]) { result += polybiusSquare[char] + ' '; } else if (char === ' ') { result += ' '; } else { result += char; } } document.getElementById('polybius-result').innerText = result; } // ========== RAIL FENCE ========== function railFenceCipher() { let text = document.getElementById('rail-input').value; let rails = parseInt(document.getElementById('rail-count').value); if (rails < 2) rails = 2; let fence = Array(rails).fill().map(() => []); let rail = 0; let direction = 1; for (let i = 0; i < text.length; i++) { fence[rail].push(text[i]); rail += direction; if (rail === rails - 1 || rail === 0) direction = -direction; } let result = ''; for (let i = 0; i < rails; i++) { result += fence[i].join(''); } document.getElementById('rail-result').innerText = result; } // ========== ПЛЯШУЩИЕ ЧЕЛОВЕЧКИ ========== const dancingFigures = { 'А': '⚑', 'Б': '⚐', 'В': '⚑⚐', 'Г': '⚐⚑', 'Д': '⚑⚑', 'Е': '⚐⚐', 'Ё': '⚑⚐⚑', 'Ж': '⚐⚑⚐', 'З': '⚑⚑⚐', 'И': '⚐⚐⚑' }; function dancingFiguresCipher() { let text = document.getElementById('dancing-input').value.toUpperCase(); let result = ''; for (let i = 0; i < text.length; i++) { let char = text[i]; if (dancingFigures[char]) { result += dancingFigures[char] + ' '; } else { result += char; } } document.getElementById('dancing-result').innerText = result; } </pre> <div class="note"> <strong>💡 Примечание:</strong> Полный код включает также стили CSS и HTML-разметку всех 8 шифров. Полная версия доступна в файле <code>src/Decoder.html</code> в репозитории. </div> <footer> <p>Проектная практика • Московский Политех • 2026</p> </footer> </div> </body> </html>