解密 @param data 待解密数据 @param key 密钥 @return byte[] 解密数据 @throws Exception
(byte[] data, byte[] key)
| 74 | * @throws Exception |
| 75 | */ |
| 76 | public static byte[] decrypt(byte[] data, byte[] key) throws NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException, NoSuchPaddingException, BadPaddingException, IllegalBlockSizeException { |
| 77 | |
| 78 | // 还原密钥 |
| 79 | Key k = toKey(key); |
| 80 | |
| 81 | // 实例化 |
| 82 | Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); |
| 83 | |
| 84 | // 初始化,设置为解密模式 |
| 85 | cipher.init(Cipher.DECRYPT_MODE, k); |
| 86 | |
| 87 | // 执行操作 |
| 88 | return cipher.doFinal(data); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * 加密 |
nothing calls this directly
no test coverage detected