-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_db.py
More file actions
57 lines (48 loc) · 1.56 KB
/
init_db.py
File metadata and controls
57 lines (48 loc) · 1.56 KB
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
from xkcdpass import xkcd_password as xp
from faker import Faker
import uuid
import hashlib
import json
fake = Faker('ru_RU')
def gen_pass():
delim = '!@$%^&*-_+=:|~?/.;'
wordfile = xp.locate_wordfile()
mywords = xp.generate_wordlist(
wordfile=wordfile,
min_length=5,
max_length=10
)
return xp.generate_xkcdpassword(
mywords,
numwords=7,
random_delimiters=True
)
def gen_users(num=100):
users = []
for i in range(num):
if i % 2:
user = {
'username': fake.user_name(),
'password': hashlib.sha256(gen_pass().encode()).hexdigest(),
'first_name': fake.first_name_male(),
'last_name': fake.last_name_male(),
'cityzen_id': f'CIT{fake.random_int(min=24565, max=56908778)}',
'token': uuid.uuid4().hex,
'privileges': 0
}
else:
user = {
'username': fake.user_name(),
'password': hashlib.sha256(gen_pass().encode()).hexdigest(),
'first_name': fake.first_name_female(),
'last_name': fake.last_name_female(),
'cityzen_id': f"CIT{fake.random_int(min=24565, max=56908778)}",
'token': uuid.uuid4().hex,
'privileges': 0
}
users.append(user)
return users
def add_posts():
with open('projects.json', 'r', encoding='utf-8') as f:
projects = json.load(f)
return projects.get('infrastructure_projects', [])