Signs the message and returns signature.

        :param: message - Message to sign
        :param: sign_key - Sign key
        :return: Signature
770613
def sign(message: bytes, sign_key: SignKey) -> Signature:
        

        logger = logging.getLogger(__name__)
        logger.debug("Bls::sign: >>> message: %r, sign_key: %r", message, sign_key)

        c_instance = c_void_p()
        do_call('indy_crypto_bls_sign',
                message, len(message),
                sign_key.c_instance,
                byref(c_instance))

        res = Signature(c_instance)

        logger.debug("Bls::sign: <<< res: %r", res)
        return res
1229220
def sign(self, msg):
        '''
        
        '''
        # Allocate a buffer large enough for the signature. Freed by ctypes.
        buf = create_string_buffer(libcrypto.RSA_size(self._rsa))
        msg = salt.utils.stringutils.to_bytes(msg)
        size = libcrypto.RSA_private_encrypt(len(msg), msg, buf, self._rsa, RSA_X931_PADDING)
        if size < 0:
            raise ValueError('Unable to encrypt message')
        return buf[0:size]
853132
def sign(self, payload):
        
        if self.authenticator:
            return self.authenticator.signed(payload)
        return payload
34941
def sign(plain_text, jws = nil, header = nil)
      jws ||= signer
      return JOSE::JWS.sign(self, plain_text, jws, header)
    end
531431
def request_signature(self, stringtosign):
        
        digest = hmac.new(
            self.secret_key.encode(ENCODING),
            stringtosign.encode(ENCODING),
            hashlib.sha1
        ).digest()
        return b64_string(digest)
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);
		}
	}
1167825
def crypto_sign(msg, sk):
    """"""
    if len(sk) != SECRETKEYBYTES:
        raise ValueError("Bad signing key length %d" % len(sk))
    vkbytes = sk[PUBLICKEYBYTES:]
    skbytes = sk[:PUBLICKEYBYTES]
    sig = djbec.signature(msg, skbytes, vkbytes)
    return sig + msg
129208
def sign(self, msg, key):
        
        h = hmac.HMAC(key, self.algorithm(), default_backend())
        h.update(msg)
        return h.finalize()
1241570
def sign(self, data):
        
        if self.signing_key is None:
            raise MissingSigningKeyError("KeyPair does not contain secret key. "
                                         "Use Keypair.from_seed method to create a new keypair with a secret key.")
        return self.signing_key.sign(data)
330758
def crypto_sign_open(signed, pk):
    
    message = ffi.new("unsigned char[]", len(signed))
    message_len = ffi.new("unsigned long long *")

    if lib.crypto_sign_open(
            message, message_len, signed, len(signed), pk) != 0:
        raise exc.BadSignatureError("Signature was forged or corrupt")

    return ffi.buffer(message, message_len[0])[:]
395564
def build_dict_to_sign(self, request, signature_headers):
        
        d = {}
        for header in signature_headers:
            if header == '(request-target)':
                continue
            d[header] = request.META.get(self.header_canonical(header))
        return d
525044
def _make_signing_request(self, message):
        """"""
        message = _helpers.to_bytes(message)

        method = 'POST'
        url = _SIGN_BLOB_URI.format(self._service_account_email)
        headers = {}
        body = json.dumps({
            'bytesToSign': base64.b64encode(message).decode('utf-8'),
        })

        self._credentials.before_request(self._request, method, url, headers)
        response = self._request(
            url=url, method=method, body=body, headers=headers)

        if response.status != http_client.OK:
            raise exceptions.TransportError(
                'Error calling the IAM signBytes API: {}'.format(
                    response.data))

        return json.loads(response.data.decode('utf-8'))
247090
def sign(self, keys):
        
        key = keys[0]
        signed = self.raw()[-2:]
        signing = base64.b64encode(key.signature(bytes(signed, 'ascii')))
        self.signatures = [signing.decode("ascii")]
26751
def get_signing_key(self, algorithm, service_context):
        
        return service_context.keyjar.get_signing_key(
            alg2keytype(algorithm), alg=algorithm)
658263
def make_signature(signer_func, data_to_sign, public_algo,
                   hashed_subpackets, unhashed_subpackets, sig_type=0):
    """"""
    # pylint: disable=too-many-arguments
    header = struct.pack('>BBBB',
                         4,         # version
                         sig_type,  # rfc4880 (section-5.2.1)
                         public_algo,
                         8)         # hash_alg (SHA256)
    hashed = subpackets(*hashed_subpackets)
    unhashed = subpackets(*unhashed_subpackets)
    tail = b'\x04\xff' + struct.pack('>L', len(header) + len(hashed))
    data_to_hash = data_to_sign + header + hashed + tail

    log.debug('hashing %d bytes', len(data_to_hash))
    digest = hashlib.sha256(data_to_hash).digest()
    log.debug('signing digest: %s', util.hexlify(digest))
    params = signer_func(digest=digest)
    sig = b''.join(mpi(p) for p in params)

    return bytes(header + hashed + unhashed +
                 digest[:2] +  # used for decoder's sanity check
                 sig)
651146
def sign(self, data):
        
        try:
            jsonstr = json.dumps(data, separators=(',', ':'))

        except TypeError as e:
            raise DataSignError(e.args[0])

        else:
            signature = self._create_signature(jsonstr)
            return self._b64encode(jsonstr + '.' + signature)
1021934
def signature_for_message_hash(self, secret_exponent, msg_hash, is_compressed):
        
        r, s, recid = self._generator.sign_with_recid(secret_exponent, msg_hash)

        # See http://bitcoin.stackexchange.com/questions/14263 and key.cpp
        # for discussion of the proprietary format used for the signature

        first = 27 + recid + (4 if is_compressed else 0)
        sig = b2a_base64(int2byte(first) + to_bytes_32(r) + to_bytes_32(s)).strip()
        sig = sig.decode("utf8")
        return sig