ROS Code
 All Classes Namespaces Files Functions Variables
secure.py
Go to the documentation of this file.
1 """
2 
3 Secure functions.
4 
5 """
6 
7 
8 def randstring(length=1):
9  """
10 
11  Generate a random string consisting of letters, digits and punctuation
12 
13  length:
14  The length of the generated string. Default is 1
15 
16  """
17  charstouse = string.ascii_letters + string.digits + string.punctuation
18  newpass = ''
19  for _ in range(length):
20  newpass += str(charstouse[random.randint(0, len(charstouse) - 1)])
21  return newpass
22 
23 
24 # Return A Random String In Hexadecimal
25 
26 
27 def tokhex(length=10, urlsafe=False):
28  if urlsafe is True:
29  return secrets.token_urlsafe(length)
30  return secrets.token_hex(length)
def randstring
Definition: secure.py:8
def tokhex
Definition: secure.py:27