-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpass.py
36 lines (29 loc) · 1.03 KB
/
pass.py
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
from flask import Flask, jsonify
import random
import string
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
def generate_password(length, password_types):
if not password_types:
password_types = ['default']
characters = ''
if 'uppercase' in password_types:
characters += string.ascii_uppercase
if 'lowercase' in password_types:
characters += string.ascii_lowercase
if 'numeric' in password_types:
characters += string.digits
if 'symbols' in password_types:
characters += "@$&*##"
if not characters:
characters = string.ascii_letters + string.digits + "@$&*#"
password = ''.join(random.choice(characters) for _ in range(length))
return password
@app.route('/password_length/<int:length>/<string:password_types>')
def generate_password_type(length, password_types):
types = password_types.split(',')
password = generate_password(length, types)
return jsonify(password=password)
if __name__ == '__main__':
app.run(debug=True,port=5000)