ابزاری قدرتمند برای رمزنگاری و رمزگشایی متون با الگوریتم سزار و نمایش گرافیکی پیشرفته
این برنامه از الگوریتم سزار برای رمزنگاری استفاده میکند که یکی از قدیمیترین و سادهترین روشهای رمزنگاری است:
// تابع رمزنگاری متن
function encryptText(text, key) {
let encrypted = '';
for(let i = 0; i < text.length; i++) {
const code = text.charCodeAt(i);
encrypted += String.fromCharCode(code + key);
}
return encrypted;
}
// تابع رمزگشایی متن
function decryptText(text, key) {
let decrypted = '';
for(let i = 0; i < text.length; i++) {
const code = text.charCodeAt(i);
decrypted += String.fromCharCode(code - key);
}
return decrypted;
}
// تابع نمایش نقاط نورانی
function drawLightPoints(text) {
lightPointsBox.innerHTML = '';
if(!text) return;
const boxWidth = lightPointsBox.clientWidth;
const boxHeight = lightPointsBox.clientHeight;
const numPoints = Math.min(text.length * 4, 200);
for(let i = 0; i < numPoints; i++) {
const point = document.createElement('div');
point.style.position = 'absolute';
point.style.width = '6px';
point.style.height = '6px';
point.style.borderRadius = '50%';
const hue = (i * 360 / numPoints + performance.now()/50) % 360;
point.style.background = `hsl(${hue}, 80%, 70%)`;
point.style.left = (Math.random() * (boxWidth - 6)) + 'px';
point.style.top = (Math.random() * (boxHeight - 6)) + 'px';
point.style.animation = `pulse 1.5s ease-in-out infinite`;
point.style.animationDelay = (Math.random() * 1.5) + 's';
lightPointsBox.appendChild(point);
}
}