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")