Files
WebAI2API/lib/security/apiKey.js
T

11 lines
227 B
JavaScript

import crypto from 'crypto';
/**
* 生成随机 API Key
* 格式: sk-{48位十六进制字符}
* @returns {string} API Key
*/
export function generateApiKey() {
return 'sk-' + crypto.randomBytes(24).toString('hex');
}