Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit edfd094

Browse files
authored
Merge branch 'main' into main
2 parents f6f1a7a + 0047406 commit edfd094

File tree

12 files changed

+347
-5
lines changed

12 files changed

+347
-5
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Anniversary Timing
2+
3+
Simple timing page implemented using flask

‎FLASK PROJECTS/Anniversary time/app.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from flask import Flask, render_template
2+
from datetime import datetime
3+
4+
app = Flask(__name__)
5+
6+
# 在此定义纪念日日期
7+
anniversary_date = datetime(2024, 6, 16)
8+
9+
@app.route('/')
10+
def index():
11+
current_date = datetime.now()
12+
delta = current_date - anniversary_date
13+
days_passed = delta.days
14+
return render_template('index.html', days_passed=days_passed, anniversary_date=anniversary_date.strftime("%Y-%m-%d %H:%M:%S"))
15+
16+
if __name__ == '__main__':
17+
app.run(debug=False)
369 KB
Loading[フレーム]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
body {
2+
margin: 0;
3+
padding: 0;
4+
font-family: Arial, sans-serif;
5+
background: url('background.jpg') no-repeat center center fixed;
6+
background-size: cover;
7+
color: white;
8+
display: flex;
9+
justify-content: center;
10+
align-items: center;
11+
height: 100vh;
12+
}
13+
14+
.container {
15+
text-align: center;
16+
background-color: rgba(0, 0, 0, 0.5);
17+
padding: 20px;
18+
border-radius: 10px;
19+
}
20+
21+
h1 {
22+
font-size: 3em;
23+
}
24+
25+
.time {
26+
font-size: 2em;
27+
margin-top: 20px;
28+
}
29+
30+
.time span {
31+
font-weight: bold;
32+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Anniversary</title>
7+
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
8+
<script>
9+
function updateTimer() {
10+
const anniversaryDate = new Date("{{ anniversary_date }}");
11+
const currentDate = new Date();
12+
const timeDiff = currentDate - anniversaryDate;
13+
14+
const days = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
15+
const hours = Math.floor((timeDiff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
16+
const minutes = Math.floor((timeDiff % (1000 * 60 * 60)) / (1000 * 60));
17+
const seconds = Math.floor((timeDiff % (1000 * 60)) / 1000);
18+
19+
document.getElementById("days").innerText = days;
20+
document.getElementById("hours").innerText = hours;
21+
document.getElementById("minutes").innerText = minutes;
22+
document.getElementById("seconds").innerText = seconds;
23+
}
24+
25+
setInterval(updateTimer, 1000);
26+
</script>
27+
</head>
28+
<body onload="updateTimer()">
29+
<div class="container">
30+
<h1>It has passed the xx anniversary</h1>
31+
<div class="time">
32+
<span id="days">0</span>
33+
<span id="hours">0</span> 小时
34+
<span id="minutes">0</span> 分钟
35+
<span id="seconds">0</span>
36+
</div>
37+
</div>
38+
</body>
39+
</html>

‎OTHERS/Encryption/README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
2+
# 🔐 Simple Symmetric Encryption in Python
3+
4+
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**.
5+
6+
---
7+
8+
## 📚 What You'll Learn
9+
10+
- How to generate secure keys
11+
- How to encrypt and decrypt messages
12+
- Basic key management (saving & loading keys)
13+
- How `Fernet` (AES-based encryption) works under the hood
14+
15+
---
16+
17+
## 🚀 Getting Started
18+
19+
### 1. Clone the Repository
20+
21+
```bash
22+
git clone https://github.com/your-username/simple-encryption-python.git
23+
cd simple-encryption-python
24+
```
25+
26+
### 2. Install Dependencies
27+
28+
Make sure you have Python 3.6+ installed.
29+
30+
Install required package using `pip`:
31+
32+
```bash
33+
pip install cryptography
34+
```
35+
36+
### 3. Run the Code
37+
38+
```bash
39+
python simple_encryption.py
40+
```
41+
42+
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:
43+
- Loads the existing key
44+
- Encrypts a sample message
45+
- Decrypts it back and displays the result
46+
47+
---
48+
49+
## 📂 File Structure
50+
51+
```
52+
simple-encryption-python/
53+
54+
├── simple_encryption.py # Main script to run encryption and decryption
55+
├── secret.key # Auto-generated AES-based symmetric key (DO NOT SHARE)
56+
├── README.md # Documentation
57+
```
58+
59+
---
60+
61+
## 🔒 Security Note
62+
63+
This example is for educational purposes only. If you’re building a production-grade application:
64+
- Never store raw keys in plaintext
65+
- Use environment variables or secure vaults (e.g., AWS KMS, HashiCorp Vault)
66+
- Handle exceptions and errors securely
67+
68+
---
69+
70+
## 🧠 How It Works (In Brief)
71+
72+
- **Fernet** is a module in the `cryptography` package that provides:
73+
- AES-128 in CBC mode
74+
- HMAC-SHA256 authentication
75+
- Random IVs for each encryption
76+
77+
- The encryption key is:
78+
- Generated once and saved to `secret.key`
79+
- Loaded on subsequent runs
80+
81+
- The message is:
82+
- Encrypted using `.encrypt()`
83+
- Decrypted using `.decrypt()`
84+
85+
---
86+
87+
## 💡 Sample Output
88+
89+
```
90+
[*] Key loaded from 'secret.key'
91+
92+
Original Message: This is a secret message.
93+
Encrypted Message: b'gAAAAABlZ...'
94+
Decrypted Message: This is a secret message.
95+
```
96+
97+
---
98+
99+
## 🤝 Contributing
100+
101+
Contributions are welcome! You can help by:
102+
- Improving the CLI interface
103+
- Adding file encryption support
104+
- Implementing password-based key derivation
105+
- Writing unit tests
106+
107+
To contribute:
108+
1. Fork the repo
109+
2. Create a new branch (`git checkout -b my-feature`)
110+
3. Commit your changes
111+
4. Push and create a Pull Request
112+
113+
---
114+
115+
## 📜 License
116+
117+
This project is licensed under the **MIT License**. See [LICENSE](LICENSE) for details.
118+
119+
---
120+
121+
## 👨‍💻 Author
122+
123+
**Afolabi Adewale**
124+
A data and security enthusiast exploring the intersection of Python, encryption, and open-source software.
125+
[GitHub Profile](https://github.com/your-username)
126+
127+
---
128+
129+
## 🔗 Related Resources
130+
131+
- [Python `cryptography` docs](https://cryptography.io/en/latest/)
132+
- [Understanding Symmetric vs Asymmetric Encryption](https://www.cloudflare.com/learning/ssl/how-does-ssl-work/)
133+
- [OWASP Crypto Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Cryptographic_Storage_Cheat_Sheet.html)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# simple_encryption.py
2+
3+
"""
4+
A simple example of symmetric encryption using Python's 'cryptography' package.
5+
6+
This script:
7+
1. Generates a secure encryption key
8+
2. Encrypts a message using the key
9+
3. Decrypts it back to the original message
10+
11+
Author: Afolabi Adewale
12+
"""
13+
14+
from cryptography.fernet import Fernet
15+
16+
# 1. Generate a key for encryption and decryption
17+
def generate_key():
18+
"""
19+
Generates a symmetric key for Fernet (uses AES encryption internally).
20+
"""
21+
key = Fernet.generate_key()
22+
with open("secret.key", "wb") as key_file:
23+
key_file.write(key)
24+
print("[+] Key generated and saved to 'secret.key'")
25+
return key
26+
27+
# 2. Load the existing key from file
28+
def load_key():
29+
"""
30+
Loads the previously generated key from the file.
31+
"""
32+
return open("secret.key", "rb").read()
33+
34+
# 3. Encrypt a message
35+
def encrypt_message(message: str, key: bytes) -> bytes:
36+
"""
37+
Encrypts a message using the provided symmetric key.
38+
"""
39+
f = Fernet(key)
40+
encrypted = f.encrypt(message.encode())
41+
return encrypted
42+
43+
44+
# 4. Decrypt a message
45+
def decrypt_message(encrypted_message: bytes, key: bytes) -> str:
46+
"""
47+
Decrypts an encrypted message using the same symmetric key.
48+
"""
49+
f = Fernet(key)
50+
decrypted = f.decrypt(encrypted_message)
51+
return decrypted.decode()
52+
53+
# 5. Main runner
54+
if __name__ == "__main__":
55+
# Create or load the key
56+
try:
57+
key = load_key()
58+
print("[*] Key loaded from 'secret.key'")
59+
except FileNotFoundError:
60+
key = generate_key()
61+
62+
# Example message
63+
message = "This is a secret message."
64+
print(f"\nOriginal Message: {message}")
65+
66+
# Encrypt it
67+
encrypted = encrypt_message(message, key)
68+
print(f"Encrypted Message: {encrypted}")
69+
70+
# Decrypt it
71+
decrypted = decrypt_message(encrypted, key)
72+
print(f"Decrypted Message: {decrypted}")

‎README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,16 @@ guide [HERE](https://github.com/larymak/Python-project-Scripts/blob/main/CONTRIB
113113
| 64 | [Umbrella Reminder](https://github.com/larymak/Python-project-Scripts/tree/main/TIME%20SCRIPTS/Umbrella%20Reminder) | [Edula Vinay Kumar Reddy](https://github.com/vinayedula) |
114114
| 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) |
115115
| 66 | [KeyLogger](https://github.com/larymak/Python-project-Scripts/tree/main/OTHERS/KeyLogger) | [Akhil](https://github.com/akhil-chagarlamudi) |
116-
| 67 | [PDF Text Extractor](https://github.com/SamAddy/Python-project-Scripts/tree/main/PYTHON%20APPS/PDF-Text-Extractor) | [Samuel Addison](https://github.com/SamAddy)
117-
| 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)
118-
| 69 | [Bitcoin Price](https://github.com/larymak/Python-project-Scripts/tree/main/WEB%20SCRAPING/Bitcoin%20Price) | [Olu-Olagbuji Delight](https://github.com/Dheelyte)
119-
| 70 | [Password Generator](https://github.com/larymak/Python-project-Scripts/tree/main/GUI/Password%20Generator) | [LpCodes](https://github.com/LpCodes)
120-
| 71 | [HTML to Excel](https://github.com/larymak/Python-project-Scripts/tree/main/CONVERSION%20SCRIPTS/HTML%20to%20Excel) | [LpCodes](https://github.com/LpCodes)
116+
| 67 | [PDF Text Extractor](https://github.com/SamAddy/Python-project-Scripts/tree/main/PYTHON%20APPS/PDF-Text-Extractor) | [Samuel Addison](https://github.com/SamAddy)|
117+
| 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)|
118+
| 69 | [Bitcoin Price](https://github.com/larymak/Python-project-Scripts/tree/main/WEB%20SCRAPING/Bitcoin%20Price) | [Olu-Olagbuji Delight](https://github.com/Dheelyte) |
119+
| 70 | [Password Generator](https://github.com/larymak/Python-project-Scripts/tree/main/GUI/Password%20Generator) | [LpCodes](https://github.com/LpCodes) |
120+
| 71 | [HTML to Excel](https://github.com/larymak/Python-project-Scripts/tree/main/CONVERSION%20SCRIPTS/HTML%20to%20Excel) | [LpCodes](https://github.com/LpCodes) |
121121
| 72 | [Star pattern](https://github.com/larymak/Python-project-Scripts/tree/main/OTHERS/Star%20pattern) | [LpCodes](https://github.com/LpCodes) |
122122
| 73 | [Logging Helper](https://github.com/larymak/Python-project-Scripts/tree/main/OTHERS/add-multiprocessing-logger) | [Jerry W.](https://github.com/Jerry0420) |
123123
| 74 | [Notepad](https://github.com/larymak/Python-project-Scripts/tree/main/PYTHON%20APPS/Notepad) | [Annarhysa Albert](https://github.com/Annarhysa) |
124124
| 75 | [Quadratic Equation Solver](https://github.com/larymak/Python-project-Scripts/tree/main/GUI/Quadratic-Equation-Solver) | [Akinfenwa Ezekiel](https://github.com/Ezek-iel) |
125125
| 76 | [Internet Connectivity Monitor](https://github.com/larymak/Python-project-Scripts/tree/main/AUTOMATION/InternetConnectivityMonitor) | [Prince Khunt](https://github.com/princekhunt) |
126126
| 76 | [E-commerce](https://github.com/larymak/Python-project-Scripts/tree/main/FLASK%20PROJECTS/E-commerce) | [Eter Nada](https://github.com/tarenjk24) |
127127
| 77 | [Resolution Swapper](https://github.com/larymak/Python-project-Scripts/tree/main/PYTHON%20APPS/ResolutionSwapper) | [KnightBlue](https://github.com/KnightBlue14) |
128+
| 78 | [Anniversary time](https://github.com/larymak/Python-project-Scripts/tree/main/FLASK%20PROJECTS/Anniversary%20time) | [gyyzzz](https://github.com/gyyzzz) |

‎gemini chatbot/Gemini-Chatbot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 9d3c59a9e3b949733d4fb3361e3abfc061d70271

‎gemini chatbot/chatbot.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import google.generativeai as genai
2+
3+
genai.configure(api_key="GOOGLE_GEMINI_API_KEY")
4+
5+
model = genai.GenerativeModel("gemini-1.5-flash")
6+
7+
chat = model.start_chat(history=[])
8+
9+
def chat_with_gemini():
10+
print("🤖 Gemini ChatBot (type 'exit' to quit)")
11+
while True:
12+
user_input = input("You: ")
13+
if user_input.lower() in ["exit", "quit"]:
14+
print("Bot: Goodbye 👋")
15+
break
16+
17+
try:
18+
response = chat.send_message(user_input)
19+
print("Bot:", response.text)
20+
except Exception as e:
21+
print("⚠️ Error:", e)
22+
23+
if __name__ == "__main__":
24+
chat_with_gemini()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /