code-center/script/release/generate-token.mjs
2025-02-24 20:27:39 +08:00

12 lines
324 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as nanoid from 'nanoid';
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
//HMAC-256推荐 32 字节。
// HMAC-512推荐 64 字节。
// jsonwentoken 默认使用 HMAC-256 算法,生成 32 字节的 token。
const v = nanoid.customAlphabet(alphabet, 32);
console.log('v', v());