public InputStream decryptFile(File privateKey, long fileId, File file) {
/*
* 创建RSAEncrypter对象
*/
RSAEncrypter encrypter = new RSAEncrypter();
/*
* 加载私钥
*/
String privateKeyPath = privateKey.getAbsolutePath();
RSAPrivateKey pKey = (RSAPrivateKey) encrypter.loadKey(privateKeyPath,
0);
/*
* 获取fileId对应的已加密数据密钥
*/
HdfsFile dfsfile = filedao.findFile(fileId);
byte[] encryptDataKey = dfsfile.getEncryptDataKey();
/*
* RSAEncrypter 对象调用解密模块,解密已加密的数据密钥
*/
byte[] dataKey = encrypter.decrypt(pKey, encryptDataKey);
/*
* 根据数据密钥,构造DesEncrypter对象
*/
// Create encrypter/decrypter class