Sign a message with a specified script_hash.

        Args:
            message (str): a hex encoded message to sign
            script_hash (UInt160): a bytearray (len 20).

        Returns:
            str: the signed message
765250
def SignMessage(self, message, script_hash):
        

        keypair = self.GetKeyByScriptHash(script_hash)
        prikey = bytes(keypair.PrivateKey)
        res = Crypto.Default().Sign(message, prikey)
        return res, keypair.PublicKey
750889
def sign(self, data):
        
        data = signing.b64_encode(data).decode()
        return self.signer.sign(data)
729195
def btc_make_p2sh_address( script_hex ):
    
    h = hashing.bin_hash160(binascii.unhexlify(script_hex))
    addr = bin_hash160_to_address(h, version_byte=multisig_version_byte)
    return addr
1323313
def sign(message, **config):
    

    if not _implementation:
        init(**config)

    return _implementation.sign(message, **config)
185256
def sign_digest(hash_hex, privkey_hex, hashfunc=hashlib.sha256):
    
    if not isinstance(hash_hex, (str, unicode)):
        raise ValueError("hash hex is not a string")

    hash_hex = str(hash_hex)

    pk_i = decode_privkey_hex(privkey_hex)
    privk = ec.derive_private_key(pk_i, ec.SECP256K1(), default_backend())

    sig = privk.sign(hash_hex.decode('hex'), ec.ECDSA(utils.Prehashed(hashes.SHA256())))

    sig_r, sig_s = decode_dss_signature(sig)
    sigb64 = encode_signature(sig_r, sig_s)
    return sigb64
739590
@Override
    public String sign(String message, byte[] key) {
        Preconditions.checkNotNull(message);
        Preconditions.checkNotNull(key);
        try {
            // Get an hmac_sha1 key from the raw key bytes
            SecretKeySpec signingKey = new SecretKeySpec(key, HMAC_SHA_1);

            // Get an hmac_sha1 Mac instance and initialize with the signing key
            Mac mac = Mac.getInstance(HMAC_SHA_1);
            mac.init(signingKey);

            // Compute the hmac on input data bytes
            byte[] rawHmac = mac.doFinal(message.getBytes(Charsets.UTF_8));

            // Convert raw bytes to Hex
            return hexToString(rawHmac);
        } catch (Exception e) {
            throw new IllegalArgumentException(e);
        }
    }
319801
def dkim_sign(message):
    

    if not HAS_DKIM:
        return message

    if not (DKIM_DOMAIN and DKIM_PRIVATE_KEY):
        return message

    sig = dkim.sign(
        message,
        DKIM_SELECTOR,
        DKIM_DOMAIN,
        DKIM_PRIVATE_KEY,
        include_headers=DKIM_HEADERS)
    return sig + message
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())
714929
def sign(message, gpg_home=None, gpg_signing_key=None, **config):
    

    if gpg_home is None or gpg_signing_key is None:
        raise ValueError("You must set the gpg_home \
                         and gpg_signing_key keyword arguments.")

    message['crypto'] = 'gpg'

    signature = _ctx.sign(
        fedmsg.encoding.dumps(message['msg']),
        gpg_signing_key,
        homedir=gpg_home
    )
    return dict(list(message.items()) + [('signature', b64encode(signature))])
129208
def sign(self, msg, key):
        
        h = hmac.HMAC(key, self.algorithm(), default_backend())
        h.update(msg)
        return h.finalize()
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)
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)
1273177
public String sign(String message) {
		try {
			final byte[] signature = signer.sign(message.getBytes(charsetName));
			return new String(Base64.encodeBase64(signature, false));
		} catch (UnsupportedEncodingException e) {
			throw new SignatureException("unsupported encoding: charsetName=" + charsetName, e);
		}
	}
902272
def serialize_input(input, signature_script_hex=''):
    
    if not (isinstance(input, dict) and 'transaction_hash' in input \
            and 'output_index' in input):
        raise Exception('Required parameters: transaction_hash, output_index')

    if is_hex(str(input['transaction_hash'])) and len(str(input['transaction_hash'])) != 64:
        raise Exception("Transaction hash '%s' must be 32 bytes" % input['transaction_hash'])

    elif not is_hex(str(input['transaction_hash'])) and len(str(input['transaction_hash'])) != 32:
        raise Exception("Transaction hash '%s' must be 32 bytes" % hexlify(input['transaction_hash']))

    if not 'sequence' in input:
        input['sequence'] = UINT_MAX

    return ''.join([
        flip_endian(input['transaction_hash']),
        hexlify(struct.pack('<I', input['output_index'])),
        hexlify(variable_length_int(len(signature_script_hex)/2)),
        signature_script_hex,
        hexlify(struct.pack('<I', input['sequence']))
    ])
1245703
def hash(ctx, message_id, message):
    
    conf = Config(message_id=message_id)

    mail = Mail(message, conf)

    logger.info(mail.header_text)
    logger.info('-' * 70)
    logger.info('Hash: {}'.format(mail.hash_key))
797099
def btc_script_hex_to_address( script_hex, segwit=None ):
    
    # TODO: make this support more than bitcoin-like scripts
    if script_hex.startswith("76a914") and script_hex.endswith("88ac") and len(script_hex) == 50:
        # p2pkh script
        hash160_bin = binascii.unhexlify(script_hex[6:-4])
        return bin_hash160_to_address(hash160_bin, version_byte=version_byte)

    elif script_hex.startswith("a914") and script_hex.endswith("87") and len(script_hex) == 46:
        # p2sh script
        hash160_bin = binascii.unhexlify(script_hex[4:-2])
        return bin_hash160_to_address(hash160_bin, version_byte=multisig_version_byte)

    elif script_hex.startswith('0014') and len(script_hex) == 44:
        # p2wpkh script (bech32 address)
        hash160_bin = binascii.unhexlify(script_hex[4:])
        return segwit_addr_encode(hash160_bin) 

    elif script_hex.startswith('0020') and len(script_hex) == 68:
        # p2wsh script (bech32 address)
        sha256_bin = binascii.unhexlify(script_hex[4:])
        return segwit_addr_encode(sha256_bin)

    return None
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