use of com.github.zhenwei.core.exception.BaseWeGooException in project LinLong-Java by zhenwei1108.
the class KeyBuilder method buildKey.
/**
* @param [keyEnum]
* @return java.security.Key
* @author zhangzhenwei
* @description 生成对称密钥
* @date 2022/2/11 22:34
* @since 1.0
*/
public Key buildKey(KeyEnum keyEnum) throws BaseWeGooException {
try {
val generator = KeyGenerator.getInstance(keyEnum.getAlg(), provider);
generator.init(keyEnum.getKeyLen(), new SecureRandom());
return generator.generateKey();
} catch (Exception e) {
throw new WeGooKeyException(KeyExceptionMessageEnum.generate_key_err, e);
}
}
Aggregations