Sign the Request object. Use this if you have an externally generated http request object you want to sign.
499522
def sign!(request, token = nil, request_options = {})
      request.oauth!(http, self, token, options.merge(request_options))
    end
752074
async def sign_url(self, url, method=HASH):
        

        token = await self.get_token()

        if method == self.QUERY:
            return patch_qs(url, {
                settings.WEBVIEW_TOKEN_KEY: token,
            })
        elif method == self.HASH:
            hash_id = 5
            p = list(urlparse(url))
            p[hash_id] = quote(token)
            return urlunparse(p)
        else:
            raise ValueError(f'Invalid signing method "{method}"')
987164
def sign(params = {})
      params = additional_params.merge(params)
      digest = params.sort_by(&:first).map{ |key, value| "#{key}=#{value}" }.join

      if oauth2_session?
        params[:sig] = Digest::MD5.hexdigest("#{digest}" + Digest::MD5.hexdigest(options[:access_token] + SchoolFriend.secret_key))
        params[:access_token] = options[:access_token]
      else
        params[:sig] = Digest::MD5.hexdigest("#{digest}#{signature}")
      end

      params
    end
1243496
@SneakyThrows
    protected Http signHttpUserPreAuthRequest(final Http request) {
        request.signRequest(
            duoProperties.getDuoIntegrationKey(),
            duoProperties.getDuoSecretKey());
        return request;
    }
677652
def sign_hmac(secret, payload)
      secret = secret.encode('ASCII')
      payload = payload.encode('ASCII')

      # Decode the private key
      raw_key = Base64.urlsafe_decode64(secret)

      # Create a signature using the private key and the URL
      digest = OpenSSL::Digest.new('sha1')
      raw_signature = OpenSSL::HMAC.digest(digest, raw_key, payload)

      # Encode the signature into base64 for url use form.
      signature =  Base64.urlsafe_encode64(raw_signature)
      return signature
    end
839784
def authenticate(self, request):
        
        jwt_value = self.get_jwt_value(request)
        if jwt_value is None:
            return None

        try:
            payload = jwt_decode_handler(jwt_value)
        except jwt.ExpiredSignature:
            msg = _('Signature has expired.')
            raise exceptions.AuthenticationFailed(msg)
        except jwt.DecodeError:
            msg = _('Error decoding signature.')
            raise exceptions.AuthenticationFailed(msg)
        except jwt.InvalidTokenError:
            raise exceptions.AuthenticationFailed()

        user = self.authenticate_credentials(payload)

        return (user, jwt_value)
200421
def request(method, path, params = {}, &block)
      token = access_token
      http = token.consumer.http
      http.read_timeout = timeout
      request = token.consumer.create_signed_request(method, path, token, {}, params, header)
      process(http, request, &block)
    end
886881
def build_signature(self, user_api_key, user_secret, request):
        """"""
        path = request.get_full_path()
        sent_signature = request.META.get(
            self.header_canonical('Authorization'))
        signature_headers = self.get_headers_from_signature(sent_signature)
        unsigned = self.build_dict_to_sign(request, signature_headers)

        # Sign string and compare.
        signer = HeaderSigner(
            key_id=user_api_key, secret=user_secret,
            headers=signature_headers, algorithm=self.ALGORITHM)
        signed = signer.sign(unsigned, method=request.method, path=path)
        return signed['authorization']
446201
def signed_uri(with_oauth = true)
      if signed?
        if with_oauth
          params = parameters
        else
          params = non_oauth_parameters
        end

        [uri, normalize(params)] * "?"
      else
        STDERR.puts "This request has not yet been signed!"
      end
    end
1299523
def _sign_multi(self, payload, signing_keys):
        
        if not isinstance(payload, Mapping):
            raise TypeError('Expecting a mapping object, as only '
                            'JSON objects can be used as payloads.')

        if not isinstance(signing_keys, list):
            raise TypeError("Expecting a list of keys")

        headers = []
        signatures = []
        payload_b64 = base64url_encode(json_encode(payload))

        for sk in signing_keys:
            signing_key = load_signing_key(sk, self.crypto_backend)

            header = self._make_header()
            header_b64 = base64url_encode(json_encode(header))
            signature_b64 = self._make_signature(header_b64, payload_b64, signing_key)

            headers.append(header_b64)
            signatures.append(signature_b64)

        jwt = {
            "header": headers,
            "payload": payload_b64,
            "signature": signatures
        }

        return jwt
887694
def _make_signature(self, header_b64, payload_b64, signing_key):
        
        token_segments = [header_b64, payload_b64]
        signing_input = b'.'.join(token_segments)

        signer = self._get_signer(signing_key)
        signer.update(signing_input)
        signature = signer.finalize()

        raw_signature = der_to_raw_signature(signature, signing_key.curve)
        return base64url_encode(raw_signature)
509290
protected Signer createSigner(final Request<?> request,
                                  final String bucketName,
                                  final String key,
                                  final boolean isAdditionalHeadRequestToFindRegion) {

        // Instead of using request.getEndpoint() for this parameter, we use endpoint which is because
        // in accelerate mode, the endpoint in request is regionless. We need the client-wide endpoint
        // to fetch the region information and pick the correct signer.
        URI uri = clientOptions.isAccelerateModeEnabled() ? endpoint : request.getEndpoint();
        final Signer signer = getSignerByURI(uri);

        if (!isSignerOverridden()) {

            if ((signer instanceof AWSS3V4Signer) && bucketRegionShouldBeCached(request)) {

                String region = bucketRegionCache.get(bucketName);
                if (region != null) {
                     // If cache contains the region for the bucket, create an endpoint for the region and
                     // update the request with that endpoint.
                     request.addHandlerContext(HandlerContextKey.SIGNING_REGION, region);
                     resolveRequestEndpoint(request, bucketName, key, RuntimeHttpUtils.toUri(RegionUtils.getRegion(region).getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration));
                     return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, region);
                } else if (request.getOriginalRequest() instanceof GeneratePresignedUrlRequest) {
                    String signerRegion = getSignerRegion();
                    if (signerRegion == null) {
                        return createSigV2Signer(request, bucketName, key);
                    }
                    return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, signerRegion);
                } else if (isAdditionalHeadRequestToFindRegion) {
                    return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, "us-east-1");
                }
            }

            String regionOverride = getSignerRegionOverride();
            if (regionOverride != null) {
                return updateSigV4SignerWithRegion(new AWSS3V4Signer(), regionOverride);
            }
        }

        if (signer instanceof S3Signer) {
            // The old S3Signer needs a method and path passed to its
            // constructor; if that's what we should use, getSigner()
            // will return a dummy instance and we need to create a
            // new one with the appropriate values for this request.
            return createSigV2Signer(request, bucketName, key);
        }

        return signer;
    }
194238
def sign(self, payload):
        
        nonce = str(int(time.time() * 1000))
        package = {'apikey': self.key,
                   'message': {'nonce': nonce, 'payload': payload}}

        signature = hmac.new(self.secret, json.dumps(payload).hexdigest,
                             hashlib.sha512).hexdigest()
        package['signature'] = signature

        return json.dumps(package)
873377
def _sign_payload(self, payload):
        
        app_key = self._app_key
        t = int(time.time() * 1000)
        requestStr = {
            'header': self._req_header,
            'model': payload
        }
        data = json.dumps({'requestStr': json.dumps(requestStr)})
        data_str = '{}&{}&{}&{}'.format(self._req_token, t, app_key, data)
        sign = hashlib.md5(data_str.encode('utf-8')).hexdigest()
        params = {
            't': t,
            'appKey': app_key,
            'sign': sign,
            'data': data,
        }
        return params
1154648
def createSign(pParams, method, host_url, request_path, secret_key):
    
    sorted_params = sorted(pParams.items(), key=lambda d: d[0], reverse=False)
    encode_params = urllib.parse.urlencode(sorted_params)
    payload = [method, host_url, request_path, encode_params]
    payload = '\n'.join(payload)
    payload = payload.encode(encoding='UTF8')
    secret_key = secret_key.encode(encoding='UTF8')

    digest = hmac.new(secret_key, payload, digestmod=hashlib.sha256).digest()
    signature = base64.b64encode(digest)
    signature = signature.decode()
    return signature
195991
def _sign_block(self, block):
        
        block_header = block.block_header
        header_bytes = block_header.SerializeToString()
        signature = self._identity_signer.sign(header_bytes)
        block.set_signature(signature)
        return block
521428
public void doSignup( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
        if (getSecurityRealm().allowsSignup()) {
            req.getView(getSecurityRealm(), "signup.jelly").forward(req, rsp);
            return;
        }
        req.getView(SecurityRealm.class, "signup.jelly").forward(req, rsp);
    }