-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoolbox.py
45 lines (34 loc) · 1.12 KB
/
toolbox.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
"""
Some tools.
@author:蔡俊熙
@license:MIT
"""
__all__ = ["dictGenerator", "getPlatform", "generateUnicodeCharacters", "generateRandomCharacters"]
def dictGenerator(**kwargs):
return kwargs
def getPlatform():
return __import__("sys").platform
def generateUnicodeCharacters(length: int = 6):
import random
passwd = []
num = ""
while True:
try:
for i in range(length):
passwd.append(chr(random.randint(1, 65536)))
for j in passwd:
num += str(ord(j))
except UnicodeEncodeError:
passwd = []
else:
break
return {"origin": "".join(passwd), "num": num}
def calculateHexFromString(string: str or bytes, sep: str = ""):
string = memoryview(bytes(string, "utf-8"))
return string.hex(sep) if sep != "" else string.hex()
def generateRandomCharacters(length: int = 6):
import random
return (''.join(
random.choice('ahui0-]}{?lubfGYUIABVEIIYYHULIAYUIIAWYAGO'
'UGAUSHIuityrtwtbyui,xmjnhcgbd9456!@#$%^'
'&*(526478253674][][') for i in range(length)))