Sign request JSON.
779497
protected JsonNode formAndSignRequestJson(Map<String, String> params) {
    CoinbeneUtils.signParams(params);
    return toJson(params);
  }
1059572
def http_signature(message, key_id, signature):
    """"""
    template = ('Signature keyId="%(keyId)s",algorithm="hmac-sha256",'
                'headers="%(headers)s",signature="%(signature)s"')
    headers = ['(request-target)', 'host', 'accept', 'date']
    return template % {
        'keyId': key_id,
        'signature': signature,
        'headers': ' '.join(headers),
    }
189717
def ToJson(self, auto_hex=True):
        
        jsn = {}
        jsn['type'] = str(ContractParameterType(self.Type))

        if self.Type == ContractParameterType.Signature:
            jsn['value'] = self.Value.hex()

        elif self.Type == ContractParameterType.ByteArray:
            if auto_hex:
                jsn['value'] = self.Value.hex()
            else:
                jsn['value'] = self.Value
        elif self.Type == ContractParameterType.Boolean:
            jsn['value'] = self.Value

        elif self.Type == ContractParameterType.String:
            jsn['value'] = str(self.Value)

        elif self.Type == ContractParameterType.Integer:
            jsn['value'] = self.Value

        # @TODO, see ``FromJson``, not sure if this is working properly
        elif self.Type == ContractParameterType.PublicKey:
            jsn['value'] = self.Value.ToString()

        elif self.Type in [ContractParameterType.Hash160,
                           ContractParameterType.Hash256]:
            jsn['value'] = self.Value.ToString()

        elif self.Type == ContractParameterType.Array:

            res = []
            for item in self.Value:
                if item:
                    res.append(item.ToJson(auto_hex=auto_hex))
            jsn['value'] = res

        elif self.Type == ContractParameterType.InteropInterface:
            try:
                jsn['value'] = self.Value.ToJson()
            except Exception as e:
                pass

        return jsn
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
313143
def sign(payload, keypair):
    """"""
    get_ed25519ll()
    #
    header = {
                "alg": ALG,
                "jwk": {
                    "kty": ALG,  # alg -> kty in jwk-08.
                    "vk": native(urlsafe_b64encode(keypair.vk))
                }
             }

    encoded_header = urlsafe_b64encode(binary(json.dumps(header, sort_keys=True)))
    encoded_payload = urlsafe_b64encode(binary(json.dumps(payload, sort_keys=True)))
    secured_input = b".".join((encoded_header, encoded_payload))
    sig_msg = ed25519ll.crypto_sign(secured_input, keypair.sk)
    signature = sig_msg[:ed25519ll.SIGNATUREBYTES]
    encoded_signature = urlsafe_b64encode(signature)

    return {"recipients":
            [{"header": native(encoded_header),
              "signature": native(encoded_signature)}],
            "payload": native(encoded_payload)}
730704
function signAWSRequest({ credentials, request }) {
  const signer = new AWS.Signers.V4(request, 'es')
  signer.addAuthorization(credentials, new Date())
  return request
}
568933
def get_json_ident(request_headers: dict) -> int:
        
        if 'HTTP_USER_AGENT' in request_headers:
            indent = 2 if re.match("[Mozilla]{7}", request_headers['HTTP_USER_AGENT']) else 0
        else:
            indent = 0

        return indent
270145
def sign_jwt(data, secret_key, expires_in, salt=None, **kw):
    
    s = itsdangerous.TimedJSONWebSignatureSerializer(secret_key=secret_key,
                                                     expires_in=expires_in,
                                                     salt=salt,
                                                      **kw)
    return s.dumps(data)
603766
def _sign_single(self, payload, signing_key):
        
        if not isinstance(payload, Mapping):
            raise TypeError('Expecting a mapping object, as only '
                            'JSON objects can be used as payloads.')

        token_segments = []

        signing_key = load_signing_key(signing_key, self.crypto_backend)

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

        token_segments = [header_b64, payload_b64, signature_b64]

        # combine the header, payload, and signature into a token and return it
        token = b'.'.join(token_segments)
        return token
235398
public function decodeSignedJsonRequest(
        RequestInterface $request,
        SigningPublicKey $publicKey
    ): array {
        /** @var array|bool $array */
        $array = \json_decode(
            $this->verifySignedStringRequest($request, $publicKey),
            true
        );
        if (!\is_array($array)) {
            throw new InvalidMessageException('Could not decode JSON');
        }
        return $array;
    }
352891
def sign_response(challenge)
      client_data_json = client_data(::U2F::ClientData::AUTHENTICATION_TYP, challenge)
      JSON.dump(
        clientData: ::U2F.urlsafe_encode64(client_data_json),
        keyHandle: ::U2F.urlsafe_encode64(key_handle_raw),
        signatureData: auth_signature_data(client_data_json)
      )
    end
1156989
def sign_request(request)
      super(request)

      if (request.respond_to?(:request_headers))
        request.request_headers['aeg-sas-key'] = @topic_key
      elsif request.respond_to?(:headers)
        request.headers['aeg-sas-key'] = @topic_key
      else
        fail ArgumentError, 'Incorrect request object was provided'
      end
    end
249379
def _signInfo(obj):
    
    lon = obj['lon']
    obj.update({
        'sign': const.LIST_SIGNS[int(lon / 30)],
        'signlon': lon % 30
    })
241145
def sign(jwk, jws = nil, header = nil)
      plain_text = to_binary
      if jws.nil?
        jwk = JOSE::JWK.from(jwk)
        jws = jwk.signer
      end
      jws = JOSE::JWS.from(jws).to_map
      if not jws.has_key?('typ')
        jws = jws.put('typ', 'JWT')
      end
      return JOSE::JWK.sign(plain_text, jws, jwk, header)
    end
123201
function RequestSigner(request, credentials) {

  if (typeof request === 'string') request = url.parse(request)

  var headers = request.headers = (request.headers || {}),
      hostParts = this.matchHost(request.hostname || request.host || headers.Host || headers.host)

  this.request = request
  this.credentials = credentials || this.defaultCredentials()

  this.service = request.service || hostParts[0] || ''
  this.region = request.region || hostParts[1] || 'us-east-1'

  // SES uses a different domain from the service name
  if (this.service === 'email') this.service = 'ses'

  if (!request.method && request.body)
    request.method = 'POST'

  if (!headers.Host && !headers.host) {
    headers.Host = request.hostname || request.host || this.createHost()

    // If a port is specified explicitly, use it as is
    if (request.port)
      headers.Host += ':' + request.port
  }
  if (!request.hostname && !request.host)
    request.hostname = headers.Host || headers.host

  this.isCodeCommitGit = this.service === 'codecommit' && request.method === 'GIT'
}
1209764
def format_status_json(self):
        """"""
        status_json = {}

        status_json['code'] = self.code
        status_json['message'] = self.message

        if self.details is not None:
            status_json['details'] = self.details

        return status_json
1351629
def prepare(self, params):
        
        jsonparams = json.dumps(params)
        payload = base64.b64encode(jsonparams.encode())
        signature = hmac.new(self.secret_key.encode(), payload,
                             hashlib.sha384).hexdigest()

        return {'X-GEMINI-APIKEY': self.api_key,
                'X-GEMINI-PAYLOAD': payload,
                'X-GEMINI-SIGNATURE': signature}