def XsrfTokenGenerate(action, user=None, timestamp=None):
  """Generate an XSRF token."""
  if not user:
    user = users.get_current_user().email()
  if not timestamp:
    timestamp = time.time()
  timestr = str(timestamp)
  try:
    secret = settings.XSRF_SECRET
  except __HOLE__:
    secret = os.urandom(16).encode('base64')[:20]
    settings.XSRF_SECRET = secret
  secret = str(secret)  # hmac secrets cannot be unicode.
  h = hmac.new(secret, XSRF_DELIMITER.join([user, action, timestr]))
  return base64.b64encode(''.join([h.digest(), XSRF_DELIMITER, timestr]))
dataset/ETHPy150Open google/simian/src/simian/mac/admin/xsrf.py/XsrfTokenGenerate