解密 @param data 数据 @param password 密码 @param salt 盐 @return byte[] 解密数据 @throws Exception
(byte[] data, String password, byte[] salt)
| 140 | * @throws Exception |
| 141 | */ |
| 142 | public static byte[] decrypt(byte[] data, String password, byte[] salt) throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidAlgorithmParameterException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException { |
| 143 | // 转换密钥 |
| 144 | Key key = toKey(password); |
| 145 | |
| 146 | // 实例化PBE参数材料 |
| 147 | PBEParameterSpec paramSpec = new PBEParameterSpec(salt, 100); |
| 148 | |
| 149 | // 实例化 |
| 150 | Cipher cipher = Cipher.getInstance(ALGORITHM); |
| 151 | |
| 152 | // 初始化 |
| 153 | cipher.init(Cipher.DECRYPT_MODE, key, paramSpec); |
| 154 | |
| 155 | // 执行操作 |
| 156 | return cipher.doFinal(data); |
| 157 | } |
| 158 | |
| 159 | } |
nothing calls this directly
no test coverage detected