forked from shaba/openuds
Fixed random password complexity
This commit is contained in:
parent
2529039f49
commit
416b5e738f
@ -91,7 +91,12 @@ class WinRandomPassManager(WindowsOsManager):
|
||||
def genPassword(self, userService: 'UserService'):
|
||||
randomPass = userService.recoverValue('winOsRandomPass')
|
||||
if not randomPass:
|
||||
randomPass = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(16))
|
||||
# Generates a password that conforms to complexity
|
||||
rnd = random.SystemRandom()
|
||||
base = ''.join(rnd.choice(v) for v in (string.ascii_lowercase, string.ascii_uppercase, string.digits)) + rnd.choice('.+-')
|
||||
randomPass = ''.join(rnd.choice(string.ascii_letters + string.digits) for _ in range(13))
|
||||
pos = rnd.randrange(0, len(randomPass))
|
||||
randomPass = randomPass[:pos] + base + randomPass[pos:]
|
||||
userService.storeValue('winOsRandomPass', randomPass)
|
||||
log.doLog(userService, log.INFO, "Password set to \"{}\"".format(randomPass), log.OSMANAGER)
|
||||
return randomPass
|
||||
|
Loading…
x
Reference in New Issue
Block a user