59 lines
1.3 KiB
Python
59 lines
1.3 KiB
Python
import csv
|
|
from faker import Faker
|
|
import hashlib
|
|
from sys import argv
|
|
|
|
SLOTS = 1000
|
|
FILENAME = "dummy_file.csv"
|
|
|
|
fake = Faker('de_DE')
|
|
|
|
fake.name()
|
|
|
|
def create_dummy_file(filename=FILENAME):
|
|
|
|
fake = Faker('de_DE')
|
|
|
|
with open(filename, 'w', newline='', encoding='utf-8') as csvfile:
|
|
fieldnames = ['Benutzername', 'Passwort']
|
|
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
|
|
writer.writerow(dict(zip(fieldnames, fieldnames)))
|
|
|
|
for _ in range(SLOTS):
|
|
username = fake.user_name()
|
|
password = fake.password(
|
|
length=5,
|
|
special_chars=False,
|
|
digits=False,
|
|
upper_case=False,
|
|
lower_case=True
|
|
)
|
|
|
|
new_hash_func = hashlib.sha256()
|
|
new_hash_func.update(password.encode('utf-8'))
|
|
new_hash_value = new_hash_func.hexdigest()
|
|
|
|
writer.writerow({'Benutzername': username, 'Passwort': new_hash_value})
|
|
|
|
print(f"Success: {SLOTS} Entries!")
|
|
|
|
|
|
def main():
|
|
global SLOTS
|
|
global FILENAME
|
|
try:
|
|
if len(argv) == 2:
|
|
SLOTS = int(argv[1])
|
|
except ValueError as e:
|
|
print(e)
|
|
exit(-1)
|
|
|
|
new_file = 'dummy_file.csv'
|
|
create_dummy_file(new_file)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|
|
|
|
|