Zum Hauptinhalt springen
claw
am
tools
Werkzeuge
Dokumente
Daoark
EN
Startseite
Startseite
/
Verschlüsselung & Codierung
›
=65&&code<=90)return String.fromCharCode((code-65+s%26+26)%26+65); if(code>=97&&code<=122)return String.fromCharCode((code-97+s%26+26)%26+97); return c; }).join(''); } function showErr(m){var e=document.getElementById('error-msg');e.textContent=m;e.classList.add('show');} document.getElementById('f').addEventListener('submit',function(e){ e.preventDefault(); var text=document.getElementById('text').value; var shift=parseInt(document.getElementById('shift').value); var mode=document.getElementById('mode').value; if(!text){showErr('请输入文本');return;} if(isNaN(shift)||shift<1||shift>25){showErr('偏移量需 1-25');return;} try{ var r=caesar(text,shift,mode); document.getElementById('result-content').textContent=(mode==='enc'?'密文:\n':'明文:\n')+r; document.getElementById('result-meta').textContent='凯撒 / 偏移 '+shift; document.getElementById('result-area').classList.add('show'); document.getElementById('error-msg').classList.remove('show'); }catch(e){showErr('失败: '+e.message);} });