code: public static byte[] decrypt(RSAPrivateKey key, byte[] encryptedData,
              String cipherTransformation) throws NoSuchAlgorithmException, NoSuchPaddingException,
              IOException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
          Cipher cipher = Cipher.getInstance(
                  StringUtils.isBlank(cipherTransformation) ? DEFAULT_CIPHER_TRANSFORMATION
                          : cipherTransformation);
          cipher.init(Cipher.DECRYPT_MODE, key);
          try (ByteArrayInputStream bois = new ByteArrayInputStream(encryptedData)) {
              try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
                  int bytesRead;
                  byte[] buf = new byte[key.getModulus().bitLength() / 8];
                  while ((bytesRead = bois.read(buf)) != -1) {
                      byte[] buff = cipher.doFinal(buf, 0, bytesRead);
                      if ("RSA/ECB/NoPadding".equals(cipherTransformation)) {
                          // remove leading zeros
                          int index = 0;
                          while (index < buff.length && buff[index] == 0)
                              index++;
                          if (index >= buff.length) {
                              buff = ArrayUtils.EMPTY_BYTE_ARRAY;
                          } else {
                              buff = Arrays.copyOfRange(buff, index, buff.length);
                          }
                      }
                      baos.write(buff);
                  }
                  return baos.toByteArray();
              }
          }
      }
docs: Decrypt encrypted data with RSA private key.
  
  <p>
  Note: if long data was encrypted using
  {@link #encrypt(RSAPublicKey, byte[], String, int)}, it will be correctly decrypted.
  </p>
  
  @param key
  @param encryptedData
  @param cipherTransformation
  cipher-transformation to use. If empty, {@link #DEFAULT_CIPHER_TRANSFORMATION}
  will be used
  @return
  @throws NoSuchAlgorithmException
  @throws NoSuchPaddingException
  @throws IOException
  @throws InvalidKeyException
  @throws IllegalBlockSizeException
  @throws BadPaddingException