std/uuid
2022-10-21 17:40:24 +09:00
..
_common.ts chore(uuid): cleanup unused internal functions (#2797) 2022-10-21 17:40:24 +09:00
mod.ts docs: Using absolute paths in jsdoc import statements (#2762) 2022-10-10 10:05:56 -04:00
README.md BREAKING std/uuid: rework v4 and v5 module (#971) 2021-07-09 14:27:41 +02:00
test.ts chore: update copyright header (#1871) 2022-02-02 23:21:39 +09:00
v1_test.ts chore: update copyright header (#1871) 2022-02-02 23:21:39 +09:00
v1.ts refactor: mark modules as browser compatible (#1972) 2022-03-01 13:25:50 +09:00
v4_test.ts chore: remove deprecated APIs across collections, streams, textproto and uuid (#2720) 2022-09-30 16:27:11 +09:00
v4.ts docs: Using absolute paths in jsdoc import statements (#2762) 2022-10-10 10:05:56 -04:00
v5_test.ts chore: update copyright header (#1871) 2022-02-02 23:21:39 +09:00
v5.ts docs: Using absolute paths in jsdoc import statements (#2762) 2022-10-10 10:05:56 -04:00

std/uuid

Generate and validate v1, v4, and v5 UUIDs.

Examples

Generate and validate a v4 (random) UUID

import { v4 } from "https://deno.land/std@$STD_VERSION/uuid/mod.ts";

// Generate a v4 UUID. For this we use the browser standard `crypto.randomUUID`
// function.
const myUUID = crypto.randomUUID();

// Validate the v4 UUID.
const isValid = v4.validate(myUUID);

Generate and validate a v5 (SHA-1 digest) UUID

import { v5 } from "https://deno.land/std@$STD_VERSION/uuid/mod.ts";

const data = new TextEncoder().encode("Hello World!");

// Generate a v5 UUID using a namespace and some data.
const myUUID = await v5.generate("6ba7b810-9dad-11d1-80b4-00c04fd430c8", data);

// Validate the v5 UUID.
const isValid = v5.validate(myUUID);