-
Notifications
You must be signed in to change notification settings - Fork 98
/
Copy pathkutil.py
28 lines (23 loc) · 840 Bytes
/
kutil.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
import string, secrets, os, binascii, time
import hashlib, subprocess
def pgen():
alphabet = string.ascii_letters + string.digits + '-_'
while True:
password = ''.join(secrets.choice(alphabet) for i in range(20))
if (sum(c.islower() for c in password) >=2
and sum(c.isupper() for c in password) >=2
and sum(c.isdigit() for c in password) >=2):
break
return password
def my_random(upper):
p = subprocess.Popen(['ps','gaux'], stdout=subprocess.PIPE)
res = p.stdout.read()
r = hashlib.md5(res)
a = int(r.hexdigest(),16)
b = int(time.time())
c = int(binascii.hexlify(os.urandom(10)), 16)
res = int(str(a) + str(b) + str(c))
return res % upper
if __name__ == "__main__":
print (my_random(100))
#print (pgen())