code: public static String encryptByPublicKey(String data, String publicKey, String fillMode) throws Exception {
  		byte[] dataByte = data.getBytes("UTf-8");
  		byte[] keyBytes = base64.decode(publicKey);
  		X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
  		KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
  		Key publicK = keyFactory.generatePublic(x509KeySpec);
  		// 对数据加密
  		// Cipher cipher = Cipher.getInstance(keyFactory.getAlgorithm());
  		Cipher cipher = Cipher.getInstance(fillMode);
  		cipher.init(Cipher.ENCRYPT_MODE, publicK);
  		int inputLen = dataByte.length;
  		ByteArrayOutputStream out = new ByteArrayOutputStream();
  		int offSet = 0;
  		byte[] cache;
  		int i = 0;
  		// 对数据分段加密
  		while (inputLen - offSet > 0) {
  			if (inputLen - offSet > MAX_ENCRYPT_BLOCK) {
  				cache = cipher.doFinal(dataByte, offSet, MAX_ENCRYPT_BLOCK);
  			} else {
  				cache = cipher.doFinal(dataByte, offSet, inputLen - offSet);
  			}
  			out.write(cache, 0, cache.length);
  			i++;
  			offSet = i * MAX_ENCRYPT_BLOCK;
  		}
  		byte[] encryptedData = out.toByteArray();
  		out.close();
  		return base64.encodeToString(encryptedData);
  	}
docs: 公钥加密
  
  @param data
  @param publicKey
  @param fillMode
  填充模式
  @return
  @throws Exception