File size: 1,996 Bytes
f6c2a8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import random as rd
import requests as req
import streamlit as st
import re

def get_random_word(wiki_page):
    url = wiki_page + "/wiki/Special:Random"
    res = req.get(url)
    title = res.url.split("/")[-1]
    title = clear_text(title)
    return title

def generate_password(lan, page):
    page = int(page)
    words = []
    for i in range(page):   
        if (lan == "English"):
            word = get_random_word(wiki_page[0])
        elif (lan == "Indonesian"):
            word = get_random_word(wiki_page[1])
        else:
            word = get_random_word(wiki_page[2])
        
        words.append(word)
    password = "".join(words)
    password = password.capitalize()
    return password

def clear_text(to_clean):
    to_clean = re.sub(r"[^a-zA-Z]+", "", to_clean)
    to_clean = to_clean.lower()
    return to_clean

wiki_page = ["https://en.wikipedia.org", "https://id.wikipedia.org", "https://su.wikipedia.org"]

st.set_page_config(
    page_title="Wikipedia Password Generator",
    layout="wide"
)

st.title("Random Password Generator")
st.info("All Password are generated from Wikipedia Page Link.\nAll generated password will have a minimum of 12 characters before symbol and numbers")

st.sidebar.header("Pick wikipedia language")
lan = st.sidebar.selectbox("Language", ["English", "Indonesian", "Sundanese"])

page = st.sidebar.selectbox("How many Wikipedia Page to Extract:", ["1", "2", "3", "4", "5"])
len_variations = st.sidebar.selectbox("How many password variations:", ["1", "2", "3", "4", "5"])

pick_symbol = st.sidebar.selectbox("Pick Symbol for Password", ["-", "_", "~"])

if (st.button("Generate Password")):
    for i in range(int(len_variations)):
        x = 0
        while (x < 12):
            generated_text = generate_password(lan, page)        
            x = len(generated_text)
            print(x)

        generated_text = generated_text + pick_symbol + str(rd.randrange(0, x))
        st.write(generated_text)
    print("Finished")