crypt fix

This commit is contained in:
Jay Lee
2020-02-07 12:59:51 -05:00
parent bc555b75dc
commit 8968833003

View File

@@ -54,7 +54,7 @@ from multiprocessing import set_start_method as mp_set_start_method
from urllib.parse import quote, urlencode, urlparse
if platform.system() == 'Windows':
# No crypt module on Win, use passlib
from passlib.hash import sha512_crypt as crypt
from passlib.hash import sha512_crypt
else:
from crypt import crypt
import dateutil.parser
@@ -1516,6 +1516,12 @@ 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):
if platform.system() == 'Windows':
return sha512_crypt.hash(password, rounds=5000)
else:
return crypt.crypt(password)
def printShowDelegates(users, csvFormat):
if csvFormat:
todrive = False
@@ -7297,7 +7303,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'] = crypt(body['password'])
body['password'] = gen_sha512_hash(body['password'])
body['hashFunction'] = 'crypt'
return body