Signs a request url with a security key.
355580
def _sign_url(self, base_url, params, security_key):
        
        import hashlib

        if six.PY3:
            from urllib.parse import urlencode, quote, quote_plus
        else:
            from urllib import urlencode, quote, quote_plus

        if not base_url or not self.security_key:
            return None

        params = params.copy()
        address = params.pop('address')

        url = base_url + '?address=' + address + '&' + urlencode(params)
        encoded_url = quote(url, safe="/:=&?#+!$,;'@()*[]")

        signature = quote_plus(encoded_url + self.security_key).encode('utf-8')
        encoded_signature = hashlib.md5(signature).hexdigest()

        return encoded_signature
839451
def headers_to_sign(self, http_request):
        
        headers_to_sign = {}
        headers_to_sign = {'Host' : self.host}
        for name, value in http_request.headers.items():
            lname = name.lower()
            if lname.startswith('x-amz'):
                headers_to_sign[name] = value
        return headers_to_sign
1071264
def sign(self, request, consumer, token):
        """"""
        key, raw = self.signing_base(request, consumer, token)

        hashed = hmac.new(key, raw, sha1)

        # Calculate the digest base 64.
        return binascii.b2a_base64(hashed.digest())[:-1]
756956
def unsign_url_safe(token, secret_key, salt=None, **kw):
    
    if len(token.split(".")) == 3:
        s = URLSafeTimedSerializer2(secret_key=secret_key, salt=salt, **kw)
        value, timestamp = s.loads(token, max_age=None, return_timestamp=True)
        now = datetime.datetime.utcnow()
        if timestamp > now:
            return value
        else:
            raise itsdangerous.SignatureExpired(
                'Signature age %s < %s ' % (timestamp, now),
                payload=value,
                date_signed=timestamp)
    else:
        s = itsdangerous.URLSafeSerializer(secret_key=secret_key, salt=salt, **kw)
        return s.loads(token)
77983
def get_plaintext_to_sign(self):
        
        as_strings = self.pack_subdomain()
        if self.sig is not None:
            # don't sign the signature
            as_strings = as_strings[:-1]

        return ",".join(as_strings)
568844
public static void signParams(Map<String, String> params) {

    String requestString =
        params.entrySet().stream()
            .sorted(Comparator.comparing(Map.Entry::getKey))
            .map(e -> e.getKey() + "=" + e.getValue())
            .map(String::toUpperCase)
            .collect(Collectors.joining("&"));

    String sign = md5(requestString).toLowerCase();

    params.put("sign", sign);
    params.remove("secret");
  }
1329981
public function signUri($uri, $secret, $paramName, $params)
    {
        $join = (bool) parse_url($uri, PHP_URL_QUERY) ? '&' : '?';

        return $uri.$join.$paramName.'='.$this->createSignature($secret, $params);
    }
838013
def signed_url
      [
        parsed_url.scheme,
        '://',
        parsed_url.host,
        parsed_url.path,
        '?',
        query_params_as_string_with_signature
      ].join.html_safe
    end
309370
def sign(key)
      raise InvalidTransaction, "Zero privkey cannot sign" if [0, '', Constant::PRIVKEY_ZERO, Constant::PRIVKEY_ZERO_HEX].include?(key)

      rawhash = Utils.keccak256 signing_data(:sign)
      key = PrivateKey.new(key).encode(:bin)

      vrs = Secp256k1.recoverable_sign rawhash, key
      self.v = encode_v(vrs[0])
      self.r = vrs[1]
      self.s = vrs[2]

      self.sender = PrivateKey.new(key).to_address

      self
    end
939498
private static function sign(string $request_body)
    {
        $app_key = self::$app_key;
        $sign = strtoupper(md5($request_body.'&app_key='.$app_key));

        return $sign;
    }
1090303
def sign(self, h):
        
        if not self.is_private():
            raise RuntimeError("Key must be private to be able to sign")
        val = from_bytes_32(h)
        r, s = self._generator.sign(self.secret_exponent(), val)
        return sigencode_der(r, s)
1088627
void sign(HttpRequest request, AuthConfig credentials, Date signingTime) {
        AwsSigner4Request sr = new AwsSigner4Request(region, service, request, signingTime);
        if(!request.containsHeader("X-Amz-Date")) {
            request.addHeader("X-Amz-Date", sr.getSigningDateTime());
        }
        request.addHeader("Authorization", task4(sr, credentials));
        final String securityToken = credentials.getAuth();
        if (StringUtils.isNotEmpty(securityToken)) {
            request.addHeader("X-Amz-Security-Token", securityToken);
        }
    }
551501
function formatUrl(p, callback) {

			// Are we signing the request?
			var sign;

			// OAuth1
			// Remove the token from the query before signing
			if (p.authResponse && p.authResponse.oauth && parseInt(p.authResponse.oauth.version, 10) === 1) {

				// OAUTH SIGNING PROXY
				sign = p.query.access_token;

				// Remove the access_token
				delete p.query.access_token;

				// Enfore use of Proxy
				p.proxy = true;
			}

			// POST body to querystring
			if (p.data && (p.method === 'get' || p.method === 'delete')) {
				// Attach the p.data to the querystring.
				_this.extend(p.query, p.data);
				p.data = null;
			}

			// Construct the path
			var path = _this.qs(p.url, p.query);

			// Proxy the request through a server
			// Used for signing OAuth1
			// And circumventing services without Access-Control Headers
			if (p.proxy) {
				// Use the proxy as a path
				path = _this.qs(p.oauth_proxy, {
					path: path,
					access_token: sign || '',

					// This will prompt the request to be signed as though it is OAuth1
					then: p.proxy_response_type || (p.method.toLowerCase() === 'get' ? 'redirect' : 'proxy'),
					method: p.method.toLowerCase(),
					suppress_response_codes: true
				});
			}

			callback(path);
		}
1036454
def signing_text(self):
        """"""
        result = "%s\n%s\n%s\n%s" % (self.endpoint.method,
                                     self.endpoint.get_canonical_host(),
                                     self.endpoint.path,
                                     self.get_canonical_query_params())
        return result
900164
def key_sign(rsakey, message, digest):
    """"""
    padding = _asymmetric.padding.PKCS1v15()
    signature = rsakey.sign(message, padding, digest)
    return signature
730704
function signAWSRequest({ credentials, request }) {
  const signer = new AWS.Signers.V4(request, 'es')
  signer.addAuthorization(credentials, new Date())
  return request
}
297287
def api_key_post(params, request_path, _async=False):
    
    method = 'POST'
    timestamp = datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%S')
    params_to_sign = {
        'AccessKeyId': ACCESS_KEY,
        'SignatureMethod': 'HmacSHA256',
        'SignatureVersion': '2',
        'Timestamp': timestamp
    }

    host_url = TRADE_URL
    host_name = urllib.parse.urlparse(host_url).hostname
    host_name = host_name.lower()
    secret_sign = createSign(params_to_sign, method, host_name,
                                             request_path, SECRET_KEY)
    params_to_sign['Signature'] = secret_sign
    if PRIVATE_KEY:
        params_to_sign['PrivateSignature'] = createPrivateSign(secret_sign, PRIVATE_KEY)
    url = host_url + request_path + '?' + urllib.parse.urlencode(params_to_sign)
    return http_post_request(url, params, _async=_async)