Sign a string of data.
    Returns signature as a base64 string
489058
def sign_raw_data(raw_data, privatekey_hex):
    
    if not isinstance(raw_data, (str, unicode)):
        raise ValueError("Data is not a string")

    raw_data = str(raw_data)

    si = ECSigner(privatekey_hex)
    si.update(raw_data)
    return si.finalize()
31753
def rsa_base64_sign_str(self, plain, b64=True):
        
        with open(self.key_file) as fp:
            key_ = RSA.importKey(fp.read())
            # h = SHA.new(plain if sys.version_info < (3, 0) else plain.encode('utf-8'))
            plain = helper.to_bytes(plain)
            # if hasattr(plain, 'encode'):
            #     plain = plain.encode()
            h = SHA.new(plain)
            cipher = pkcs.new(key_).sign(h)
            cip = base64.b64encode(cipher) if b64 else cipher
            return helper.to_str(cip)
136157
def string_to_sign(self):
        
        return (AWS4_HMAC_SHA256 + "\n" +
                self.request_timestamp + "\n" +
                self.credential_scope + "\n" +
                sha256(self.canonical_request.encode("utf-8")).hexdigest())
1039628
protected String signAndBase64Encode(String data, String key,
            SigningAlgorithm algorithm) throws SdkClientException {
        return signAndBase64Encode(data.getBytes(UTF8), key, algorithm);
    }
531431
def request_signature(self, stringtosign):
        
        digest = hmac.new(
            self.secret_key.encode(ENCODING),
            stringtosign.encode(ENCODING),
            hashlib.sha1
        ).digest()
        return b64_string(digest)
1288213
def _sign(self,params):
        '''
        
        '''
        for k, v in params.iteritems():
            if type(v) == int: v = str(v)
            elif type(v) == float: v = '%.2f'%v
            elif type(v) in (list, set): 
                v = ','.join([str(i) for i in v])
            elif type(v) == bool: v = 'true' if v else 'false'
            elif type(v) == datetime.datetime: v = v.strftime('%Y-%m-%d %X')
            if type(v) == unicode:
                params[k] = v.encode('utf-8')
            else:
                params[k] = v
        src = self.APP_SECRET + ''.join(["%s%s" % (k, v) for k, v in sorted(params.iteritems())])
        return md5(src).hexdigest().upper()
510385
function sign (privateKey, data) {
  const pair = ECPair.fromWIF(privateKey)
  return btcMessage.sign(data, pair.d.toBuffer(32), pair.compressed).toString('base64')
}
74989
def sign(self):
        """"""
        payload = self._payload()
        sigin = b'.'.join([self.protected.encode('utf-8'), payload])
        signature = self.engine.sign(self.key, sigin)
        return {'protected': self.protected,
                'payload': payload,
                'signature': base64url_encode(signature)}
1034187
def calculate_signature key, string_to_sign
      hmac = HMAC::SHA1.new(key)
      hmac.update(string_to_sign)
      signature = Base64.encode64(hmac.digest).gsub("\n", '')
      if $DEBUG
        puts "Signature #{signature}"
      end
      signature
    end
1066787
def reg_signature(client_data_json)
      payload = [
        "\x00",
        ::U2F::DIGEST.digest(app_id),
        ::U2F::DIGEST.digest(client_data_json),
        key_handle_raw,
        origin_public_key_raw
      ].join
      cert_key.sign(::U2F::DIGEST.new, payload)
    end
708063
def _sha256_sign(self, method, url, headers, body):
        
        d = ''
        sign_headers = method.upper() + '|' + url + '|'
        for key, value in sorted(headers.items()):
            if key.startswith('X-Mcash-'):
                sign_headers += d + key.upper() + '=' + value
                d = '&'

        rsa_signature = base64.b64encode(
            self.signer.sign(SHA256.new(sign_headers)))

        return 'RSA-SHA256 ' + rsa_signature
318925
def sign(self, data: bytes, v: int = 27) -> Signature:
        
        assert v in (0, 27), 'Raiden is only signing messages with v in (0, 27)'
        _hash = eth_sign_sha3(data)
        signature = self.private_key.sign_msg_hash(message_hash=_hash)
        sig_bytes = signature.to_bytes()
        # adjust last byte to v
        return sig_bytes[:-1] + bytes([sig_bytes[-1] + v])
544442
function signSubscription () {
    var to_sign = args.sid + ':' + args.channel + '.' + args.resource +
                  ':ttl=' + args.ttl + ':read=' + args.read +
                  ':write=' + args.write

    if (self.bbt.userinfo.userid) {
      to_sign = to_sign + ':userid=' + self.bbt.userinfo.userid
    }

    var signature = crypto.createHmac('sha1', self.bbt.transport.secretKey)
    .update(to_sign)
    .digest('base64')

    var auth = {
      auth: self.bbt.transport.key + ':' + signature
    }

    if (self.bbt.userinfo.userid) {
      auth.userid = self.bbt.userinfo.userid
    }

    return auth
  }
683786
def sign(s, passphrase, sig_format=SER_COMPACT, curve='secp160r1'):
    
    if isinstance(s, six.text_type):
        raise ValueError("Encode `s` to a bytestring yourself to" +
                         " prevent problems with different default encodings")
    curve = Curve.by_name(curve)
    privkey = curve.passphrase_to_privkey(passphrase)
    return privkey.sign(hashlib.sha512(s).digest(), sig_format)
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)
564738
def signed_raw(self) -> str:
        
        raw = self.raw()
        signed = "\n".join(self.signatures)
        signed_raw = raw + signed + "\n"
        return signed_raw
1203473
def _generate_signature(self, nonce, method, path, data):
        

        data_json = ""
        endpoint = path
        if method == "get":
            if data:
                query_string = self._get_params_for_sig(data)
                endpoint = "{}?{}".format(path, query_string)
        elif data:
            data_json = compact_json_dict(data)
        sig_str = ("{}{}{}{}".format(nonce, method.upper(), endpoint, data_json)).encode('utf-8')
        m = hmac.new(self.API_SECRET.encode('utf-8'), sig_str, hashlib.sha256)
        return base64.b64encode(m.digest())