File size: 1,519 Bytes
80287e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import random
import string
from pyrogram import Client, filters, enums
from Devine import app

def generate_strong_password(length):
    # Define character sets
    lowercase = string.ascii_lowercase
    uppercase = string.ascii_uppercase
    digits = string.digits
    special_chars = "!@#$%^&*()_+"

    # Ensure the password has at least one character from each set
    password = [
        random.choice(lowercase),
        random.choice(uppercase),
        random.choice(digits),
        random.choice(special_chars),
    ]

    # Fill the rest of the password length with random choices from all sets
    all_chars = lowercase + uppercase + digits + special_chars
    password += random.choices(all_chars, k=length - len(password))

    # Shuffle to prevent predictable patterns
    random.shuffle(password)
    
    # Join the list into a string
    return ''.join(password)

@app.on_message(filters.command(["genpass", 'genpw', "genpassword"]))
async def password(bot, update):
    message = await update.reply_text(text="ᴘʀᴏᴄᴇꜱꜱɪɴɢ...")
    
    if len(update.command) > 1:
        qw = update.text.split(" ", 1)[1]
    else:
        ST = ["12", "14", "16", "18", "20"]  # Stronger password length
        qw = random.choice(ST)
    
    limit = int(qw)
    random_value = generate_strong_password(limit)
    
    txt = f"<b>ʟɪᴍɪᴛ :</b> {str(limit)} \n<b> ᴘᴀꜱꜱᴡᴏʀᴅ: <code>{random_value}</code>"
    
    await message.edit_text(text=txt, parse_mode=enums.ParseMode.HTML)