export default () => { // Human readable alphabet (a-z, 0-9 without l, o, 0, 1 to avoid confusion) const alphabet = "abcdefghijkmnpqrstuvwxyz23456789"; // Generate 24 bytes = 192 bits of entropy. // We're only going to use 5 bits per byte so the total entropy will be 192 * 5 / 8 = 120 bits const bytes = new Uint8Array(24); crypto.getRandomValues(bytes); let id = ""; for (let i = 0; i < bytes.length; i++) { // >> 3 "removes" the right-most 3 bits of the byte id += alphabet[bytes[i] >> 3]; } return id; }