unoffical wafrn mirror
wafrn.net
atproto
social-network
activitypub
1import crypto from 'crypto'
2
3export default function generateRandomString() {
4 return crypto.createHash('sha1').update(Math.random().toString()).digest('hex')
5}
6
7export function generateRandomStringInviteCode() {
8 const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
9 const code = Array.from({ length: 4 }, () => {
10 return Array.from({ length: 4 }, () => {
11 return chars[Math.floor(Math.random() * chars.length)];
12 }).join('');
13 }).join('-');
14 return code
15}