解密 @param data 待解密数据 @param key 密钥 @return byte[] 解密数据 @throws Exception
(byte[] data, byte[] key)
| 183 | * @throws Exception |
| 184 | */ |
| 185 | public static byte[] decrypt(byte[] data, byte[] key) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException { |
| 186 | |
| 187 | // 生成本地密钥 |
| 188 | SecretKey secretKey = new SecretKeySpec(key, SECRET_KEY_ALGORITHM); |
| 189 | |
| 190 | // 数据解密 |
| 191 | Cipher cipher = Cipher.getInstance(secretKey.getAlgorithm()); |
| 192 | |
| 193 | cipher.init(Cipher.DECRYPT_MODE, secretKey); |
| 194 | |
| 195 | return cipher.doFinal(data); |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * 构建密钥 |
nothing calls this directly
no test coverage detected