-
Notifications
You must be signed in to change notification settings - Fork 0
/
passGne.py
64 lines (51 loc) · 2.04 KB
/
passGne.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
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
# Author: h3key
# Version: 1.0
# All credit to h3key
import random
import string
import tkinter as tk
from tkinter import filedialog
def passwords(word, quantity):
special_characters = '@_-*/+.' # you can add or remove characters here
numbers = string.digits
similar_passwords = []
for _ in range(quantity):
modified_word = ''.join(random.choice([char.lower(), char.upper()]) for char in word)
modified_word += random.choice(numbers)
special_char_pos = random.randint(1, len(modified_word) - 1)
modified_word = (
modified_word[:special_char_pos] +
random.choice(special_characters) +
modified_word[special_char_pos:]
)
# Adjust the length of the word between 8 and 11 characters; you can modify the parameters for more or less length :D
final_length = random.randint(8, 11)
while len(modified_word) < final_length:
modified_word += random.choice(string.ascii_letters + numbers + special_characters)
# Limit the maximum length to 11 characters
if len(modified_word) > 11:
modified_word = modified_word[:11]
similar_passwords.append(modified_word)
return similar_passwords
def select_file_and_save(content):
root = tk.Tk()
root.withdraw()
file_path = filedialog.asksaveasfilename(
title="Save file",
defaultextension=".txt",
filetypes=[("Text files", "*.txt"), ("All files", "*.*")]
)
if file_path:
with open(file_path, 'w') as file:
for line in content:
file.write(line + '\n')
print(f"Generated passwords saved in {file_path}")
else:
print("Save canceled.")
# Request base word
base_word = input("Enter the base word: ")
password_quantity = int(input("Enter the number of similar passwords: "))
# Generate similar passwords
generated_passwords = passwords(base_word, password_quantity)
# Save the passwords in a file selected by the user
select_file_and_save(generated_passwords)