Skip to content

[pull] main from larymak:main #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions FLASK PROJECTS/Anniversary time/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Anniversary Timing

Simple timing page implemented using flask
17 changes: 17 additions & 0 deletions FLASK PROJECTS/Anniversary time/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from flask import Flask, render_template
from datetime import datetime

app = Flask(__name__)

# 在此定义纪念日日期
anniversary_date = datetime(2024, 6, 16)

@app.route('/')
def index():
current_date = datetime.now()
delta = current_date - anniversary_date
days_passed = delta.days
return render_template('index.html', days_passed=days_passed, anniversary_date=anniversary_date.strftime("%Y-%m-%d %H:%M:%S"))

if __name__ == '__main__':
app.run(debug=False)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions FLASK PROJECTS/Anniversary time/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background: url('background.jpg') no-repeat center center fixed;
background-size: cover;
color: white;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}

.container {
text-align: center;
background-color: rgba(0, 0, 0, 0.5);
padding: 20px;
border-radius: 10px;
}

h1 {
font-size: 3em;
}

.time {
font-size: 2em;
margin-top: 20px;
}

.time span {
font-weight: bold;
}
39 changes: 39 additions & 0 deletions FLASK PROJECTS/Anniversary time/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Anniversary</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<script>
function updateTimer() {
const anniversaryDate = new Date("{{ anniversary_date }}");
const currentDate = new Date();
const timeDiff = currentDate - anniversaryDate;

const days = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
const hours = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((timeDiff % (1000 * 60)) / 1000);

document.getElementById("days").innerText = days;
document.getElementById("hours").innerText = hours;
document.getElementById("minutes").innerText = minutes;
document.getElementById("seconds").innerText = seconds;
}

setInterval(updateTimer, 1000);
</script>
</head>
<body onload="updateTimer()">
<div class="container">
<h1>It has passed the xx anniversary</h1>
<div class="time">
<span id="days">0</span> 天
<span id="hours">0</span> 小时
<span id="minutes">0</span> 分钟
<span id="seconds">0</span> 秒
</div>
</div>
</body>
</html>
133 changes: 133 additions & 0 deletions OTHERS/Encryption/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

# 🔐 Simple Symmetric Encryption in Python

This project demonstrates the basics of **symmetric encryption** using Python and the [`cryptography`](https://cryptography.io/en/latest/) library. It's a great starting point for beginners interested in **cybersecurity**, **cryptography**, or contributing to **open-source security tools**.

---

## 📚 What You'll Learn

- How to generate secure keys
- How to encrypt and decrypt messages
- Basic key management (saving & loading keys)
- How `Fernet` (AES-based encryption) works under the hood

---

## 🚀 Getting Started

### 1. Clone the Repository

```bash
git clone https://github.com/your-username/simple-encryption-python.git
cd simple-encryption-python
```

### 2. Install Dependencies

Make sure you have Python 3.6+ installed.

Install required package using `pip`:

```bash
pip install cryptography
```

### 3. Run the Code

```bash
python simple_encryption.py
```

On first run, it will generate a `secret.key` file that is used for both encryption and decryption. Each time you run the script, it:
- Loads the existing key
- Encrypts a sample message
- Decrypts it back and displays the result

---

## 📂 File Structure

```
simple-encryption-python/
├── simple_encryption.py # Main script to run encryption and decryption
├── secret.key # Auto-generated AES-based symmetric key (DO NOT SHARE)
├── README.md # Documentation
```

---

## 🔒 Security Note

This example is for educational purposes only. If you’re building a production-grade application:
- Never store raw keys in plaintext
- Use environment variables or secure vaults (e.g., AWS KMS, HashiCorp Vault)
- Handle exceptions and errors securely

---

## 🧠 How It Works (In Brief)

- **Fernet** is a module in the `cryptography` package that provides:
- AES-128 in CBC mode
- HMAC-SHA256 authentication
- Random IVs for each encryption

- The encryption key is:
- Generated once and saved to `secret.key`
- Loaded on subsequent runs

- The message is:
- Encrypted using `.encrypt()`
- Decrypted using `.decrypt()`

---

## 💡 Sample Output

```
[*] Key loaded from 'secret.key'

Original Message: This is a secret message.
Encrypted Message: b'gAAAAABlZ...'
Decrypted Message: This is a secret message.
```

---

## 🤝 Contributing

Contributions are welcome! You can help by:
- Improving the CLI interface
- Adding file encryption support
- Implementing password-based key derivation
- Writing unit tests

To contribute:
1. Fork the repo
2. Create a new branch (`git checkout -b my-feature`)
3. Commit your changes
4. Push and create a Pull Request

---

## 📜 License

This project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.

---

## 👨‍💻 Author

**Afolabi Adewale**
A data and security enthusiast exploring the intersection of Python, encryption, and open-source software.
[GitHub Profile](https://github.com/your-username)

---

## 🔗 Related Resources

- [Python `cryptography` docs](https://cryptography.io/en/latest/)
- [Understanding Symmetric vs Asymmetric Encryption](https://www.cloudflare.com/learning/ssl/how-does-ssl-work/)
- [OWASP Crypto Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html)
72 changes: 72 additions & 0 deletions OTHERS/Encryption/symmetricEncryption.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# simple_encryption.py

"""
A simple example of symmetric encryption using Python's 'cryptography' package.

This script:
1. Generates a secure encryption key
2. Encrypts a message using the key
3. Decrypts it back to the original message

Author: Afolabi Adewale
"""

from cryptography.fernet import Fernet

# 1. Generate a key for encryption and decryption
def generate_key():
"""
Generates a symmetric key for Fernet (uses AES encryption internally).
"""
key = Fernet.generate_key()
with open("secret.key", "wb") as key_file:
key_file.write(key)
print("[+] Key generated and saved to 'secret.key'")
return key

# 2. Load the existing key from file
def load_key():
"""
Loads the previously generated key from the file.
"""
return open("secret.key", "rb").read()

# 3. Encrypt a message
def encrypt_message(message: str, key: bytes) -> bytes:
"""
Encrypts a message using the provided symmetric key.
"""
f = Fernet(key)
encrypted = f.encrypt(message.encode())
return encrypted


# 4. Decrypt a message
def decrypt_message(encrypted_message: bytes, key: bytes) -> str:
"""
Decrypts an encrypted message using the same symmetric key.
"""
f = Fernet(key)
decrypted = f.decrypt(encrypted_message)
return decrypted.decode()

# 5. Main runner
if __name__ == "__main__":
# Create or load the key
try:
key = load_key()
print("[*] Key loaded from 'secret.key'")
except FileNotFoundError:
key = generate_key()

# Example message
message = "This is a secret message."
print(f"\nOriginal Message: {message}")

# Encrypt it
encrypted = encrypt_message(message, key)
print(f"Encrypted Message: {encrypted}")

# Decrypt it
decrypted = decrypt_message(encrypted, key)
print(f"Decrypted Message: {decrypted}")
21 changes: 21 additions & 0 deletions PYTHON APPS/ResolutionSwapper/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Resolution
This is a small application for switching monitor resolution without having to go into your computer settings. Very useful if you have an older system, and are having trouble running newer/more demanding games.

# Prerequisites
pywintypes
win32con
win32api
time
Pyinstaller (optional, but recommended)

# Usage
This app currently features 720p, 1080p and 1440p resolutions. If you wish to add more, add them in the same format as the other resolutions. The number is a string, so you could choose to set the input to letters if that is your preference.

When run, the app will create a popup terminal for you to enter the resolution you want. It will first check if what you input is valid, then set your monitor's resolution based on the preset dimensions.

# Export to exe
For ease of use, I'd recommend exporting this to an exe using pyinstaller.
Instructions for this can be found here -
```https://pyinstaller.org/en/stable/usage.html```
From there, create a shortcut to have it on your taskbar. To set the image, you can use any image you choose, but it will need to be in a .ico format. You can find converters to make these from other formats online.
That done, simply click on the icon, then enter your resolution in the terminal popup (only the width).
30 changes: 30 additions & 0 deletions PYTHON APPS/ResolutionSwapper/ResolutionMulti.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import pywintypes
import win32con
import win32api
import time


devmode = pywintypes.DEVMODEType()
valid = 0
while valid == 0:
heightinp = input('Set resolution: -- ')
if heightinp in ['720','1080','1440']:
valid += 1
else:
print('Invalid resolution. Please try again')
time.sleep(2)


if heightinp == '720':
devmode.PelsWidth = 1280
devmode.PelsHeight =720
if heightinp == '1080':
devmode.PelsWidth = 1920
devmode.PelsHeight =1080
if heightinp == '1440':
devmode.PelsWidth = 2560
devmode.PelsHeight = 1440

devmode.Fields = win32con.DM_PELSWIDTH | win32con.DM_PELSHEIGHT

win32api.ChangeDisplaySettings(devmode, 0)
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,16 @@ guide [HERE](https://github.com/larymak/Python-project-Scripts/blob/main/CONTRIB
| 64 | [Umbrella Reminder](https://github.com/larymak/Python-project-Scripts/tree/main/TIME%20SCRIPTS/Umbrella%20Reminder) | [Edula Vinay Kumar Reddy](https://github.com/vinayedula) |
| 65 | [Image to PDF](https://github.com/larymak/Python-project-Scripts/tree/main/IMAGES%20%26%20PHOTO%20SCRIPTS/Image%20to%20PDF) | [Vedant Chainani](https://github.com/Envoy-VC) |
| 66 | [KeyLogger](https://github.com/larymak/Python-project-Scripts/tree/main/OTHERS/KeyLogger) | [Akhil](https://github.com/akhil-chagarlamudi) |
| 67 | [PDF Text Extractor](https://github.com/SamAddy/Python-project-Scripts/tree/main/PYTHON%20APPS/PDF-Text-Extractor) | [Samuel Addison](https://github.com/SamAddy)
| 68 | [Analyze docx file](https://github.com/larymak/Python-project-Scripts/tree/main/AUTOMATION/analyzing%20and%20writing%20.docx%20file) | [Kashaan Mahmood](https://github.com/Kashaan-M)
| 69 | [Bitcoin Price](https://github.com/larymak/Python-project-Scripts/tree/main/WEB%20SCRAPING/Bitcoin%20Price) | [Olu-Olagbuji Delight](https://github.com/Dheelyte)
| 70 | [Password Generator](https://github.com/larymak/Python-project-Scripts/tree/main/GUI/Password%20Generator) | [LpCodes](https://github.com/LpCodes)
| 71 | [HTML to Excel](https://github.com/larymak/Python-project-Scripts/tree/main/CONVERSION%20SCRIPTS/HTML%20to%20Excel) | [LpCodes](https://github.com/LpCodes)
| 67 | [PDF Text Extractor](https://github.com/SamAddy/Python-project-Scripts/tree/main/PYTHON%20APPS/PDF-Text-Extractor) | [Samuel Addison](https://github.com/SamAddy)|
| 68 | [Analyze docx file](https://github.com/larymak/Python-project-Scripts/tree/main/AUTOMATION/analyzing%20and%20writing%20.docx%20file) | [Kashaan Mahmood](https://github.com/Kashaan-M)|
| 69 | [Bitcoin Price](https://github.com/larymak/Python-project-Scripts/tree/main/WEB%20SCRAPING/Bitcoin%20Price) | [Olu-Olagbuji Delight](https://github.com/Dheelyte) |
| 70 | [Password Generator](https://github.com/larymak/Python-project-Scripts/tree/main/GUI/Password%20Generator) | [LpCodes](https://github.com/LpCodes) |
| 71 | [HTML to Excel](https://github.com/larymak/Python-project-Scripts/tree/main/CONVERSION%20SCRIPTS/HTML%20to%20Excel) | [LpCodes](https://github.com/LpCodes) |
| 72 | [Star pattern](https://github.com/larymak/Python-project-Scripts/tree/main/OTHERS/Star%20pattern) | [LpCodes](https://github.com/LpCodes) |
| 73 | [Logging Helper](https://github.com/larymak/Python-project-Scripts/tree/main/OTHERS/add-multiprocessing-logger) | [Jerry W.](https://github.com/Jerry0420) |
| 74 | [Notepad](https://github.com/larymak/Python-project-Scripts/tree/main/PYTHON%20APPS/Notepad) | [Annarhysa Albert](https://github.com/Annarhysa) |
| 75 | [Quadratic Equation Solver](https://github.com/larymak/Python-project-Scripts/tree/main/GUI/Quadratic-Equation-Solver) | [Akinfenwa Ezekiel](https://github.com/Ezek-iel) |
| 76 | [Internet Connectivity Monitor](https://github.com/larymak/Python-project-Scripts/tree/main/AUTOMATION/InternetConnectivityMonitor) | [Prince Khunt](https://github.com/princekhunt) |
| 76 | [E-commerce](https://github.com/larymak/Python-project-Scripts/tree/main/FLASK%20PROJECTS/E-commerce) | [Eter Nada](https://github.com/tarenjk24) |

| 77 | [Resolution Swapper](https://github.com/larymak/Python-project-Scripts/tree/main/PYTHON%20APPS/ResolutionSwapper) | [KnightBlue](https://github.com/KnightBlue14) |
| 78 | [Anniversary time](https://github.com/larymak/Python-project-Scripts/tree/main/FLASK%20PROJECTS/Anniversary%20time) | [gyyzzz](https://github.com/gyyzzz) |
1 change: 1 addition & 0 deletions gemini chatbot/Gemini-Chatbot
Submodule Gemini-Chatbot added at 9d3c59
Loading
Loading