mirror of
https://github.com/haiwen/seahub.git
synced 2025-10-22 03:16:34 +00:00
fix Use of a broken or weak cryptographic hashing (#7671)
Co-authored-by: lian <imwhatiam123@gmail.com>
This commit is contained in:
@@ -115,7 +115,10 @@ class RegistrationManager(models.Manager):
|
||||
username = user.username
|
||||
if isinstance(username, str):
|
||||
username = username.encode('utf-8')
|
||||
activation_key = hashlib.sha1(salt+username).hexdigest()
|
||||
|
||||
# Take the first 16 character to avoid errors.
|
||||
# (1406, "Data too long for column 'activation_key' at row 1")
|
||||
activation_key = hashlib.sha256(salt+username).hexdigest()[:16]
|
||||
return self.create(emailuser_id=user.id,
|
||||
activation_key=activation_key)
|
||||
|
||||
|
Reference in New Issue
Block a user