import { randomBytes } from 'crypto'
function generateUuid4(): string {
const time = Date.now();
const timeHex = time.toString(16).padStart(12, '0');
const randomHex = randomBytes(4).toString('hex');
const variant = '8'; // The variant for UUIDv4 is always '8'
const version = '4'; // The version for UUIDv4 is always '4'
return `${timeHex}-4${randomHex.substr(1, 3)}-${version}${randomHex.substr(4, 3)}-${variant}${randomHex.substr(7)}`;
}
console.log(generateUuid4())
To embed this program on your website, copy the following code and paste it into your website's HTML: