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);
		}
	}
public byte [ ] sign ( byte [ ] message ) { try { 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 ) ; } }
Signs a message.

@param message the message to sign
@return the signature