def valid_csrf_token(req, session_id, csrf_token):
 try:
  when = int(csrf_token.split('-')[0], 16)
  return ((when > (time.time() - CSRF_VALIDITY)) and (csrf_token == make_csrf_token(req, session_id, ts=when)))
 except (ValueError, IndexError):
  return False

def valid_csrf_token ( req , session_id , csrf_token ) : try : when = int ( csrf_token . split ( '-' ) [ 0 ] , 16 ) return ( ( when > ( time . time ( ) - CSRF_VALIDITY ) ) and ( csrf_token == make_csrf_token ( req , session_id , ts = when ) ) ) except ( ValueError , IndexError ) : return False
check the validity of a csrf token .