code: public String sign(final String message) throws EncryptionException {
        try {
           Signature sign = Signature.getInstance("SHA1withRSA");
           sign.initSign(privateKey);
           sign.update(message.getBytes(DEFAULT_CHARSET));
  
           return new String(Base64.encodeBase64(sign.sign()), DEFAULT_CHARSET);
        } catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) {
           throw new EncryptionException("Unable to sign message: ", e);
        }
     }
docs: Signs the message with the private key.
  
  @param message
  The message to be signed.
  @return The signature.
  @throws EncryptionException
  When it was not possible to sign the message.