rest_framework_security/otp/engines/webauthn.py
def generate_challenge(challenge_len=CHALLENGE_DEFAULT_BYTE_LEN):
    """Generate a challenge of challenge_len bytes, Base64-encoded.
    We use URL-safe base64, but we *don't* strip the padding, so that
    the browser can decode it without too much hassle.
    Note that if we are doing byte comparisons with the challenge in collectedClientData
    later on, that value will not have padding, so we must remove the padding
    before storing the value in the session.
    """
    # If we know Python 3.6 or greater is available, we could replace this with one
    # call to secrets.token_urlsafe
    challenge_bytes = os.urandom(challenge_len)
    challenge_base64 = base64.urlsafe_b64encode(challenge_bytes)
    # Python 2/3 compatibility: b64encode returns bytes only in newer Python versions
    if not isinstance(challenge_base64, str):
        challenge_base64 = challenge_base64.decode("utf-8")
    return challenge_base64
Generate a challenge of challenge_len bytes, Base64-encoded.
    We use URL-safe base64, but we *don't* strip the padding, so that
    the browser can decode it without too much hassle.
    Note that if we are doing byte comparisons with the challenge in collectedClientData
    later on, that value will not have padding, so we must remove the padding
    before storing the value in the session.
    
Generate a challenge of challenge_len bytes, Base64-encoded.
We use URL-safe base64, but we *don't* strip the padding, so that
the browser can decode it without too much hassle.
Note that if we are doing byte comparisons with the challenge in collectedClientData
later on, that value will not have padding, so we must remove the padding
before storing the value in the session.
Generate a challenge of challenge_len bytes Base64 - encoded . We use URL - safe base64 but we * don ' t * strip the padding so that the browser can decode it without too much hassle . Note that if we are doing byte comparisons with the challenge in collectedClientData later on that value will not have padding so we must remove the padding before storing the value in the session .
def generate_challenge(challenge_len=CHALLENGE_DEFAULT_BYTE_LEN):
    challenge_bytes = os.urandom(challenge_len)
    challenge_base64 = base64.urlsafe_b64encode(challenge_bytes)
    if not isinstance(challenge_base64, str):
        challenge_base64 = challenge_base64.decode("utf-8")
    return challenge_base64
def generate_challenge ( challenge_len = CHALLENGE_DEFAULT_BYTE_LEN ) : challenge_bytes = os . urandom ( challenge_len ) challenge_base64 = base64 . urlsafe_b64encode ( challenge_bytes ) if not isinstance ( challenge_base64 , str ) : challenge_base64 = challenge_base64 . decode ( "utf-8" ) return challenge_base64
Generate a challenge of challenge_len bytes, Base64-encoded.
Generate a challenge of challenge_len bytes Base64 - encoded .
"""Generate a challenge of challenge_len bytes, Base64-encoded.
    We use URL-safe base64, but we *don't* strip the padding, so that
    the browser can decode it without too much hassle.
    Note that if we are doing byte comparisons with the challenge in collectedClientData
    later on, that value will not have padding, so we must remove the padding
    before storing the value in the session.
    """ # If we know Python 3.6 or greater is available, we could replace this with one # call to secrets.token_urlsafe # Python 2/3 compatibility: b64encode returns bytes only in newer Python versions
challenge_len