mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
初次提交
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import crypto from 'crypto';
|
||||
|
||||
/**
|
||||
* 生成随机 API Key
|
||||
* 格式: sk- + 32位十六进制字符串
|
||||
*/
|
||||
function generateApiKey() {
|
||||
const buffer = crypto.randomBytes(16);
|
||||
const hex = buffer.toString('hex');
|
||||
return `sk-${hex}`;
|
||||
}
|
||||
|
||||
const key = generateApiKey();
|
||||
console.log('\n=== API Key 生成器 ===');
|
||||
console.log('您的新 API Key 是:');
|
||||
console.log('\x1b[32m%s\x1b[0m', key); // 绿色高亮
|
||||
console.log('\n请将其复制到 config.yaml 的 server.auth 字段中。');
|
||||
console.log('======================\n');
|
||||
Reference in New Issue
Block a user