Signs a message.

@param message the message to sign
@return the signature
553206
public byte[] sign(byte[] message) {
		try {
			// this way signatureInstance should be thread safe
			final Signature signatureInstance = ((provider == null) || (provider.length() == 0)) ? Signature
					.getInstance(algorithm) : Signature.getInstance(algorithm, provider);
			signatureInstance.initSign(privateKey);
			signatureInstance.update(message);
			return signatureInstance.sign();
		} catch (Exception e) {
			throw new SignatureException("error generating the signature: algorithm=" + algorithm, e);
		}
	}
150087
public String sign(BoxSignatureAlgorithm algorithm, String key, String webHookPayload, String deliveryTimestamp) {
        return Base64.encode(this.signRaw(algorithm, key, webHookPayload, deliveryTimestamp));
    }
184074
public KeyVerifyParameters withSignature(byte[] signature) {
        if (signature == null) {
            this.signature = null;
        } else {
            this.signature = Base64Url.encode(signature);
        }
        return this;
    }
564527
protected static String message(Object message)
  {
    if(message == null) {
      return null;
    }
    if(!(message instanceof Throwable)) {
      return message.toString();
    }

    Throwable t = (Throwable)message;
    if(t.getCause() == null) {
      return t.toString();
    }

    int nestingLevel = 0;
    StringBuilder sb = new StringBuilder();
    for(;;) {
      sb.append(t.getClass().getName());
      sb.append(":");
      sb.append(" ");
      if(++nestingLevel == 8) {
        sb.append("...");
        break;
      }
      if(t.getCause() == null) {
        String s = t.getMessage();
        if(s == null) {
          t.getClass().getCanonicalName();
        }
        sb.append(s);
        break;
      }
      t = t.getCause();
    }
    return sb.toString();
  }
841738
@Override
    public Message newMessage(final String message) {
        final ReusableSimpleMessage result = getSimple();
        result.set(message);
        return result;
    }
799222
async def sign(self, message: bytes) -> bytes:
        

        LOGGER.debug('BaseAnchor.sign >>> message: %s', message)

        if not self.wallet.handle:
            LOGGER.debug('BaseAnchor.sign <!< Wallet %s is closed', self.name)
            raise WalletState('Wallet {} is closed'.format(self.name))

        rv = await self.wallet.sign(message)

        LOGGER.debug('BaseAnchor.sign <<< %s', rv)
        return rv
627401
public byte [] detached(byte [] message) {
            byte[] signedMsg = this.sign(message);
            byte[] sig = new byte[signatureLength];
            for (int i = 0; i < sig.length; i++)
                sig[i] = signedMsg[i];
            return sig;
        }
1306171
public byte[] sendWithResult(final byte[] message) {
        synchronized (webSocketHandler.getNotifyResultObject()) {
            webSocketHandler.sendMessage(message);

            try {
                webSocketHandler.getNotifyResultObject().wait(TimeUnit.SECONDS.toMillis(ANSWER_TIMEOUT));
            }
            catch (InterruptedException e) {
                return null;
            }

            return webSocketHandler.getResultBytes();
        }
    }
606445
public String sign(String msg) {
        try {
            RSAPrivateKey key = getPrivateKey();
            Signature sig = Signature.getInstance(SIGNING_ALGORITHM + "with" + key.getAlgorithm());
            sig.initSign(key);
            sig.update(msg.getBytes(StandardCharsets.UTF_8));
            return hudson.remoting.Base64.encode(sig.sign());
        } catch (GeneralSecurityException e) {
            throw new SecurityException(e);
        }
    }
743735
public String sign(String signatureBaseString) {
    try {
      Mac mac = Mac.getInstance(MAC_NAME);
      mac.init(key);
      byte[] text = signatureBaseString.getBytes("UTF-8");
      byte[] signatureBytes = mac.doFinal(text);
      signatureBytes = Base64.encodeBase64(signatureBytes);
      String signature = new String(signatureBytes, "UTF-8");

      if (LOG.isDebugEnabled()) {
        LOG.debug("signature base: " + signatureBaseString);
        LOG.debug("signature: " + signature);
      }

      return signature;
    }
    catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException(e);
    }
    catch (InvalidKeyException e) {
      throw new IllegalStateException(e);
    }
    catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }
1323313
def sign(message, **config):
    

    if not _implementation:
        init(**config)

    return _implementation.sign(message, **config)
527962
public boolean verify(byte[] message, byte[] signature) {
		try {
			// this way signatureInstance should be thread safe
			final Signature signatureInstance = ((provider == null) || (provider.length() == 0)) ? Signature
					.getInstance(algorithm) : Signature.getInstance(algorithm, provider);
			signatureInstance.initVerify(publicKey);
			signatureInstance.update(message);
			return signatureInstance.verify(signature);
		} catch (java.security.SignatureException e) {
			return false;
		} catch (Exception e) {
			throw new SignatureException("error verifying signature", e);
		}
	}
974279
public static BinaryTypeSignature createTypeSignature(String signature) {
//		if (!isSignature(signature)) {
//			throw new IllegalArgumentException(signature);
//		}
		if (signature.charAt(signature.length() - 1) != ';')
			return new BinaryTypeSignature(signature);
		return new BinaryGenericTypeSignature(signature);
	}
1092897
public byte[] sign(String privateKeyId, byte[] message) {
		Signer signer = cache.get(privateKeyId);

		if (signer != null) {
			return signer.sign(message);
		}

		SignerImpl signerImpl = new SignerImpl();
		PrivateKey privateKey = privateKeyMap.get(privateKeyId);

		if (privateKey == null) {
			throw new SignatureException("private key not found: privateKeyId=" + privateKeyId);
		}

		signerImpl.setPrivateKey(privateKey);
		signerImpl.setAlgorithm(algorithm);
		signerImpl.setProvider(provider);
		cache.put(privateKeyId, signerImpl);
		return signerImpl.sign(message);
	}
1219579
private function sign(Message &$message)
    {
        // generate signature
        $signature = $this->generateSignature();

        // first remove the empty dkim header
        $message->getHeaders()->removeHeader('DKIM-Signature');

        // generate new header set starting with the dkim header
        $headerSet[] = new Dkim($this->getEmptyDkimHeader()->getFieldValue() . $signature);

        // then append existing headers
        $headers = $message->getHeaders();
        foreach($headers as $header) {
            $headerSet[] = $header;
        }

        // clear headers
        $message->getHeaders()->clearHeaders();

        // add the newly created header set with the dkim signature
        $message->getHeaders()->addHeaders($headerSet);
    }
248749
public CallActivityMock onExecutionSendMessage(final String message) {
    return onExecutionDo(execution -> execution.getProcessEngineServices()
      .getRuntimeService().correlateMessage(message));
  }
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))])