-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
72 lines (62 loc) · 2.62 KB
/
app.py
File metadata and controls
72 lines (62 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from flask import Flask, render_template, request, redirect, url_for, flash
import sqlite3
import secrets
import string
app = Flask(__name__)
app.secret_key = "key_storm_at_2025_final"
DB_NAME = "passwords.db"
def init_db():
with sqlite3.connect(DB_NAME) as conn:
conn.execute('''
CREATE TABLE IF NOT EXISTS passwords (
id INTEGER PRIMARY KEY AUTOINCREMENT,
website TEXT NOT NULL,
password TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
''')
conn.commit()
init_db()
# فقط کاراکترهایی که ۱۰۰٪ همه جا قبول میشه (حتی بانک ملت، دیجیکالا، اینستا، گوگل)
def generate_password(length=20):
length = max(8, min(100, int(length)))
# این مجموعه دقیقاً همونیه که همه سایتهای دنیا قبول دارن
allowed_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+-"
return ''.join(secrets.choice(allowed_chars) for _ in range(length))
@app.route('/', methods=['GET', 'POST'])
def index():
password = None
if request.method == 'POST':
website = request.form.get('website', '').strip()
try:
length = int(request.form.get('length', 20))
except:
length = 20
if not website:
flash('اسم سایت رو بنویس داداش!', 'error')
else:
password = generate_password(length)
with sqlite3.connect(DB_NAME) as conn:
conn.execute("INSERT INTO passwords (website, password) VALUES (?, ?)", (website, password))
conn.commit()
flash(f'رمز امن برای {website} ساخته شد!', 'success')
return render_template('index.html', password=password)
@app.route('/passwords')
def show_passwords():
with sqlite3.connect(DB_NAME) as conn:
conn.row_factory = sqlite3.Row
cur = conn.cursor()
cur.execute("SELECT * FROM passwords ORDER BY created_at DESC")
passwords = cur.fetchall()
return render_template('passwords.html', passwords=passwords)
@app.route('/delete/<int:pw_id>')
def delete_password(pw_id):
with sqlite3.connect(DB_NAME) as conn:
conn.execute("DELETE FROM passwords WHERE id = ?", (pw_id,))
conn.commit()
flash('رمز حذف شد!', 'success')
return redirect(url_for('show_passwords'))
if __name__ == '__main__':
print("KeyStorm v3.0 - ۱۰۰٪ امن و بدون مشکل کپی!")
app.run(host='127.0.0.1', port=5000, debug=True, use_reloader=False)