package com.zydc.ixctempproject;
import lombok.extern.slf4j.Slf4j;
import java.security.SecureRandom;
import java.util.Base64;
/**
* <功能描述>
*
* @author sunzhanchao
* @date 2025/7/31 09:52
* @copyright cestc.cn
*/
@Slf4j
public class KeyGenMain {
// appKey: LTAI5tC6P5AaDUqXxZbeMqCa appKey的长度为24位
// appSecret: n7o5mLpbVsOXvsFq5W5Px1zWPMSemd appSecret的长度为30位
private static final SecureRandom random = new SecureRandom();
public static void main(String[] args) {
String key = keyGen(random);
String secret = secretGen(random);
log.info("key: \t{}", key);
log.info("secret: \t{}", secret);
}
private static String keyGen(SecureRandom random) {
byte[] bytes = new byte[16];
random.nextBytes(bytes);
String val = Base64.getUrlEncoder().withoutPadding().encodeToString(bytes);
return val;
}
private static String secretGen(SecureRandom random) {
byte[] bytes = new byte[22];
random.nextBytes(bytes);
String val = Base64.getUrlEncoder().withoutPadding().encodeToString(bytes);
return val;
}
}