生成密钥 @return byte[] 二进制密钥 @throws Exception
()
| 128 | * @throws Exception |
| 129 | */ |
| 130 | public static byte[] initKey() throws NoSuchAlgorithmException { |
| 131 | // 实例化 |
| 132 | KeyGenerator kg = KeyGenerator.getInstance(KEY_ALGORITHM); |
| 133 | |
| 134 | /* |
| 135 | * AES 要求密钥长度为 128位、192位或 256位 |
| 136 | */ |
| 137 | kg.init(256); |
| 138 | |
| 139 | // 生成秘密密钥 |
| 140 | SecretKey secretKey = kg.generateKey(); |
| 141 | |
| 142 | // 获得密钥的二进制编码形式 |
| 143 | return secretKey.getEncoded(); |
| 144 | } |
| 145 | |
| 146 | |
| 147 | } |
nothing calls this directly
no test coverage detected