-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrandom_name.py
More file actions
27 lines (24 loc) · 777 Bytes
/
Copy pathrandom_name.py
File metadata and controls
27 lines (24 loc) · 777 Bytes
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
import random
import uuid
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
dlenght = {1: 3,
2: 6,
3: 4,
4: 5}
def random_uid():
name = []
rlenght = random.choice(list(dlenght.keys()))
for i in range(dlenght[rlenght]):
name.append(random.choice(letters))
return ''.join(name)
def random_hostname(wordlist='wordlist.txt', sep='-'):
with open(wordlist, encoding='UTF-8') as wd:
words = [i.replace('\n', '') for i in wd.readlines()]
rchoice = random.choice(words)
u = random_uid()
if rchoice == 'android':
return rchoice+sep+str(uuid.uuid4())
if random.choice(list(dlenght.keys())) % 2:
return u+sep+rchoice
else:
return (u+sep+rchoice).upper()