ItsMeAnanyaSrivastava/Data-Privacy-Sem5-DU
This Repository contains data privacy practicals of Delhi University 5th Semester.
Data Privacy - Semester 5 (Delhi University)
This repository contains practical implementations for the Data Privacy course, offered in the 5th semester at Delhi University. The practicals cover fundamental concepts of cryptography, password security, and digital signatures using Python.
๐ Table of Contents
๐ฏ About
This repository serves as a comprehensive collection of Python programs demonstrating various data privacy and security concepts. Each practical is designed to help students understand the implementation and application of different cryptographic techniques and security practices.
๐ Practicals Overview
| Practical | Topic | Description |
|---|---|---|
| P1 | Caesar Cipher | Substitutional cipher for encryption/decryption |
| P2 | Fernet Encryption | Symmetric encryption using cryptography library |
| P3 | SHA-256 Hashing | Password hashing using SHA-256 algorithm |
| P4 | Password Leak Checker | Check passwords against breach databases |
| P5 | Password Generator | Generate secure passwords from dictionary words |
| P6 | Brute Force Attack | Simulate password cracking attempts |
| P7 | Digital Signatures | RSA-based document signing and verification |
๐ง Prerequisites
Before running these practicals, ensure you have the following installed:
- Python 3.6+ (Python 3.8 or higher recommended)
- pip (Python package installer)
๐ฆ Installation
-
Clone the repository:
git clone https://github.com/ItsMeAnanyaSrivastava/Data-Privacy-Sem5-DU.git cd Data-Privacy-Sem5-DU -
Install required dependencies:
pip install cryptography requests
Or create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install cryptography requests
๐ Usage
Each practical can be run independently using Python:
python P1.py
python P2.py
# ... and so onSome practicals may require additional files (e.g., a.csv for P4, dictionary.txt for P5). Ensure these files are present in the same directory before running.
๐ Practical Details
P1: Caesar Cipher
Concept: Substitutional cipher - one of the simplest encryption techniques
What it does:
- Encrypts text by shifting each letter by a fixed number of positions in the alphabet
- Decrypts the encrypted text back to original form
- Preserves case (uppercase/lowercase) and non-alphabetic characters
How to run:
python P1.pyExample:
Enter the text to be encrypted: Hello World
Enter the shift value (1-25): 3
Encrypted text: Khoor Zruog
Decrypted text: Hello World
P2: Fernet Encryption
Concept: Symmetric encryption using the Fernet encryption scheme
What it does:
- Generates a secure encryption key
- Encrypts data using the Fernet symmetric encryption
- Decrypts the encrypted data back to original form
How to run:
python P2.pyExample:
Enter the text to be encrypted: Sensitive Information
Encrypted text: b'gAAAAABl...'
Decrypted text: Sensitive Information
P3: SHA-256 Password Hashing
Concept: One-way cryptographic hashing for password storage
What it does:
- Takes a password as input
- Generates a SHA-256 hash of the password
- Returns the hash as a hexadecimal string
How to run:
python P3.pyExample:
Enter the password to be hashed: mySecurePassword123
Hashed password: 3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2g3h4
P4: Password Leak Checker
Concept: Checking passwords against known data breaches using Have I Been Pwned API
What it does:
- Reads username-password pairs from a CSV file
- Checks each password against the Have I Been Pwned database
- Reports which passwords have been compromised
Prerequisites:
- Create a file named
a.csvwith username,password pairs (one per line)
How to run:
python P4.pyExample CSV format (a.csv):
user1,password123
user2,securePass456
Output:
Password for user user1 has been leaked
Password for user name user2 is safe
P5: Dictionary-based Password Generator
Concept: Generating strong passwords using dictionary words
What it does:
- Reads words from a dictionary file
- Randomly selects and combines words to create a password
- Provides a more memorable yet secure password option
Prerequisites:
- Create a file named
dictionary.txtwith one word per line
How to run:
python P5.pyExample dictionary.txt:
apple
banana
cherry
dragon
Output:
Generated password: applecherrydragon
P6: Brute Force Attack Simulation
Concept: Demonstrating password vulnerability through brute force
What it does:
- Attempts to crack a password by trying all possible combinations
- Shows the number of attempts needed to find the password
- Warning: Can be very time-consuming for longer passwords!
How to run:
python P6.pyExample:
Enter Password: abc
Password Found: abc in 12345 attempts
Note: For educational purposes only. Use short passwords for testing (1-3 characters recommended).
P7: Digital Signature
Concept: RSA-based digital signatures for document authentication
What it does:
- Generates RSA public-private key pair
- Signs a document using the private key
- Verifies the signature using the public key
- Demonstrates non-repudiation and authenticity
How to run:
python P7.pyOutput:
Document: b'Confidential document needs to be signed'
Signature: 3d4e5f6g7h8i...
โ
Signature is valid.
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
๐ค Contributing
Contributions are welcome! If you'd like to contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/improvement) - Make your changes
- Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/improvement) - Create a Pull Request
๐ง Contact
For questions or suggestions, please open an issue in this repository.
Disclaimer: These programs are for educational purposes only. Use them responsibly and ethically. Do not use the brute force or password checking tools for malicious purposes.