mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-05 16:51:12 -07:00
Merge branch 'CURA-8401_use_secrets_instead_of_random'
This commit is contained in:
commit
d5481e4ce8
1 changed files with 3 additions and 3 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import json
|
import json
|
||||||
import random
|
import secrets
|
||||||
from hashlib import sha512
|
from hashlib import sha512
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
@ -139,11 +139,11 @@ class AuthorizationHelpers:
|
||||||
def generateVerificationCode(code_length: int = 32) -> str:
|
def generateVerificationCode(code_length: int = 32) -> str:
|
||||||
"""Generate a verification code of arbitrary length.
|
"""Generate a verification code of arbitrary length.
|
||||||
|
|
||||||
:param code_length:: How long should the code be? This should never be lower than 16, but it's probably
|
:param code_length:: How long should the code be in bytes? This should never be lower than 16, but it's probably
|
||||||
better to leave it at 32
|
better to leave it at 32
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return "".join(random.choice("0123456789ABCDEF") for i in range(code_length))
|
return secrets.token_hex(code_length)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def generateVerificationCodeChallenge(verification_code: str) -> str:
|
def generateVerificationCodeChallenge(verification_code: str) -> str:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue