Skip to content

Commit fdc7bd6

Browse files
bobsbobs
authored andcommitted
New function for generating random strings
1 parent 4ca8756 commit fdc7bd6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import ntpath
1212
from subprocess import STDOUT, Popen, PIPE
1313
from socket import inet_aton
14-
import os
14+
import os, random, string
1515

1616
def generateUniqueNameFile ():
1717
'''
@@ -223,4 +223,8 @@ def stringToLinePadded(string, padValue=" "):
223223
padding = padValue*(sizeTerm - (len(string) % sizeTerm) -4)
224224
return string+padding
225225

226+
def generateRandomString (length=20):
227+
'''
228+
'''
229+
return ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(length))
226230

0 commit comments

Comments
 (0)