-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (29 loc) · 995 Bytes
/
main.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
37
import streamlit as st
import random
def generate_password(length, special):
if special:
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()'
else:
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
# print(len(chars))
password = ''
for i in range(length):
index = random.randint(0, (len(chars) - 1))
# print(index)
char = chars[index]
password += char
return password
# pass_length = int(input('password length : '))
# print(generate_password(12))
st.title('Random Password Generator')
number = st.number_input('Password length', min_value=1)
st.write('Password length : ' + str(number))
special_chars = True
if st.checkbox('Include Special characters'):
special_chars = True
else:
special_chars = False
if st.button('Generate Password'):
st.text(generate_password(int(number), special=special_chars))
else:
st.text('Password will display here')