def _compute_signature(parameters, access_key_secret):
 def percent_encode(line):
  if (not isinstance(line, str)):
   return line
  s = line
  if (sys.stdin.encoding is None):
   s = line.decode().encode('utf8')
  else:
   s = line.decode(sys.stdin.encoding).encode('utf8')
  res = _quote(s, '')
  res = res.replace('+', '%20')
  res = res.replace('*', '%2A')
  res = res.replace('%7E', '~')
  return res
 sortedParameters = sorted(list(parameters.items()), key=(lambda items: items[0]))
 canonicalizedQueryString = ''
 for (k, v) in sortedParameters:
  canonicalizedQueryString += ((('&' + percent_encode(k)) + '=') + percent_encode(v))
 stringToSign = ('GET&%2F&' + percent_encode(canonicalizedQueryString[1:]))
 h = hmac.new((access_key_secret + '&'), stringToSign, sha1)
 signature = base64.encodestring(h.digest()).strip()
 return signature

def _compute_signature ( parameters , access_key_secret ) : def percent_encode ( line ) : if ( not isinstance ( line , str ) ) : return line s = line if ( sys . stdin . encoding is None ) : s = line . decode ( ) . encode ( 'utf8' ) else : s = line . decode ( sys . stdin . encoding ) . encode ( 'utf8' ) res = _quote ( s , '' ) res = res . replace ( '+' , '%20' ) res = res . replace ( '*' , '%2A' ) res = res . replace ( '%7E' , '~' ) return res sortedParameters = sorted ( list ( parameters . items ( ) ) , key = ( lambda items : items [ 0 ] ) ) canonicalizedQueryString = '' for ( k , v ) in sortedParameters : canonicalizedQueryString += ( ( ( '&' + percent_encode ( k ) ) + '=' ) + percent_encode ( v ) ) stringToSign = ( 'GET&%2F&' + percent_encode ( canonicalizedQueryString [ 1 : ] ) ) h = hmac . new ( ( access_key_secret + '&' ) , stringToSign , sha1 ) signature = base64 . encodestring ( h . digest ( ) ) . strip ( ) return signature
generate an api request signature .