Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

uuid.ts

9 lines337 Bytes

1import * as Crypto from "expo-crypto";
2​
3export const uuidv4 = () => Crypto.randomUUID();
4​
5/** Random lowercase hex string of `byteLength` bytes (2 chars per byte). */
6export const randomHex = (byteLength: number): string =>
7 Array.from(Crypto.getRandomBytes(byteLength), (byte) => byte.toString(16).padStart(2, "0")).join(
8 "",
9 );