Use crypt for password hash on *nix

This commit is contained in:
Jay Lee
2020-02-07 11:02:21 -05:00
parent 34567480a2
commit 3acf6e50a7
2 changed files with 7 additions and 6 deletions

View File

@@ -52,7 +52,11 @@ from multiprocessing import Pool as mp_pool
from multiprocessing import freeze_support as mp_freeze_support
from multiprocessing import set_start_method as mp_set_start_method
from urllib.parse import quote, urlencode, urlparse
from passlib.hash import sha512_crypt
try:
from crypt import crypt
except ImportError:
# No crypt module on Win, use passlib
from passlib.hash import crypt
import dateutil.parser
import googleapiclient
@@ -1512,9 +1516,6 @@ def addDelegates(users, i):
print("Giving %s delegate access to %s (%s/%s)" % (delegate, delegator, i, count))
gapi.call(gmail.users().settings().delegates(), 'create', soft_errors=True, userId='me', body={'delegateEmail': delegate})
def gen_sha512_hash(password):
return sha512_crypt.hash(password, rounds=5000)
def printShowDelegates(users, csvFormat):
if csvFormat:
todrive = False
@@ -7296,7 +7297,7 @@ def getUserAttributes(i, cd, updateCmd):
rnd = SystemRandom()
body['password'] = ''.join(rnd.choice(PASSWORD_SAFE_CHARS) for _ in range(100))
if 'password' in body and need_to_hash_password:
body['password'] = gen_sha512_hash(body['password'])
body['password'] = crypt(body['password'])
body['hashFunction'] = 'crypt'
return body