Code example for PublicKey

Methods: getAlgorithm

0
 
		// 取得公钥 
		PublicKey publicKey = getPublicKeyByCertificate(certificatePath);
 
		// 对数据加密 
		Cipher cipher = Cipher.getInstance(publicKey.getAlgorithm());
		cipher.init(Cipher.ENCRYPT_MODE, publicKey);
 
		return cipher.doFinal(data);
 
	} 
 
	/** 
	 * 公钥解密 
	 *  
	 * @param data 
	 *            待解密数据 
	 * @param certificatePath 
	 *            证书路径 
	 * @return byte[] 解密数据 
	 * @throws Exception