auth/__init__.py
def _create_security_token(user):
    """Create a CHIRP security token.

    Args:
      user: A User object.

    Returns:
      A string containing an encrypted security token that encodes
      the user's email address as well as a timestamp.
    """
    timestamp = int(time.time())
    plaintext = "%x %s" % (timestamp, user.email)
    nearest_mult_of_16 = 16 * ((len(plaintext) + 15) // 16)
    # Pad plaintest with whitespace to make the length a multiple of 16,
    # as this is a requirement of AES encryption.
    plaintext = plaintext.rjust(nearest_mult_of_16, ' ')
    if _DISABLE_CRYPTO:
        body = plaintext
        sig = "sig"
    else:
        key_storage = KeyStorage.get()
        body = AES.new(key_storage.aes_key, AES.MODE_CBC).encrypt(plaintext)
        hmac_key = key_storage.hmac_key
        if type(hmac_key) == unicode:
            # Crypto requires byte strings
            hmac_key = hmac_key.encode('utf8')
        sig = HMAC.HMAC(key=hmac_key, msg=body).hexdigest()
    return '%s:%s' % (sig, body)
Create a CHIRP security token.

    Args:
      user: A User object.

    Returns:
      A string containing an encrypted security token that encodes
      the user's email address as well as a timestamp.
    
Create a CHIRP security token.
Create a CHIRP security token .
def _create_security_token(user):
    timestamp = int(time.time())
    plaintext = "%x %s" % (timestamp, user.email)
    nearest_mult_of_16 = 16 * ((len(plaintext) + 15) // 16)
    plaintext = plaintext.rjust(nearest_mult_of_16, ' ')
    if _DISABLE_CRYPTO:
        body = plaintext
        sig = "sig"
    else:
        key_storage = KeyStorage.get()
        body = AES.new(key_storage.aes_key, AES.MODE_CBC).encrypt(plaintext)
        hmac_key = key_storage.hmac_key
        if type(hmac_key) == unicode:
            hmac_key = hmac_key.encode('utf8')
        sig = HMAC.HMAC(key=hmac_key, msg=body).hexdigest()
    return '%s:%s' % (sig, body)
def _create_security_token ( user ) : timestamp = int ( time . time ( ) ) plaintext = "%x %s" % ( timestamp , user . email ) nearest_mult_of_16 = 16 * ( ( len ( plaintext ) + 15 ) // 16 ) plaintext = plaintext . rjust ( nearest_mult_of_16 , ' ' ) if _DISABLE_CRYPTO : body = plaintext sig = "sig" else : key_storage = KeyStorage . get ( ) body = AES . new ( key_storage . aes_key , AES . MODE_CBC ) . encrypt ( plaintext ) hmac_key = key_storage . hmac_key if type ( hmac_key ) == unicode : hmac_key = hmac_key . encode ( 'utf8' ) sig = HMAC . HMAC ( key = hmac_key , msg = body ) . hexdigest ( ) return '%s:%s' % ( sig , body )
Create a CHIRP security token.
Create a CHIRP security token .
"""Create a CHIRP security token.

    Args:
      user: A User object.

    Returns:
      A string containing an encrypted security token that encodes
      the user's email address as well as a timestamp.
    """ # Pad plaintest with whitespace to make the length a multiple of 16, # as this is a requirement of AES encryption. # Crypto requires byte strings
A string containing an encrypted security token that encodes
the user's email address as well as a timestamp.
A string containing an encrypted security token that encodes the user ' s email address as well as a timestamp .
user
A User object.
A User object .