.strength-bar {
height: 10px;
background: #ddd;
border-radius: 4px;
overflow: hidden;
margin-top: 5px;
}
.bar {
height: 100%;
transition: width 0.3s;
}
button {
background: #1e3a8a;
color: white;
border: none;
padding: 8px 16px;
border-radius: 6px;
cursor: pointer;
}
button:hover { background: #3b82f6; }
Password Strength Tester
Strength: Weak
// Password Strength Tester
const password = document.getElementById(‘password’);
const bar = document.getElementById(‘bar’);
const text = document.getElementById(‘strength-text’);
password.addEventListener(‘input’, () => {
const val = password.value;
let score = 0;
if (val.length >= 8) score++;
if (/[A-Z]/.test(val)) score++;
if (/[0-9]/.test(val)) score++;
if (/[^A-Za-z0-9]/.test(val)) score++;
let strength = [‘Weak’, ‘Fair’, ‘Good’, ‘Strong’];
let colors = [‘red’, ‘orange’, ‘gold’, ‘green’];
bar.style.width = (score / 4) * 100 + ‘%’;
bar.style.background = colors[score – 1] || ‘red’;
text.textContent = ‘Strength: ‘ + (strength[score – 1] || ‘Weak’);
});
// Quiz logic
function gradeQuiz() {
let score = 0;
const q1 = document.querySelectorAll(‘input[name=”q1″]’)[0].checked;
const q2 = document.querySelectorAll(‘input[name=”q2″]’)[0].checked;
if (q1) score++;
if (q2) score++;
document.getElementById(‘score’).innerText = `You scored ${score}/2`;
}
Introduction to Cybersecurity
Cybersecurity is the practice of protecting systems, networks, and data from digital attacks. These attacks are usually aimed at accessing, changing, or destroying sensitive information.
Confidentiality: Protects data from unauthorized access.
Integrity: Keeps information accurate and unchanged.
Availability: Ensures data and systems are accessible when needed.
2. Common Cyber Threats
- Malware (Viruses, Worms, Trojans)
- Phishing (Fake emails to steal information)
- DDoS Attacks (Overloading servers)
- SQL Injection (Database manipulation)
- Man-in-the-Middle Attack (Intercepting communications)
3. Defense Strategies
- Use strong passwords and 2FA
- Install antivirus and firewall
- Encrypt data and backup regularly
- Keep software updated
- Be aware of phishing scams