Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/uuid/mod.ts>v5.generate

The Deno Standard Library
Go to Latest
function v5.generate
import { v5 } from "https://deno.land/std@0.222.1/uuid/mod.ts";
const { generate } = v5;

Generate a RFC4122 v5 UUID (SHA-1 namespace).

Examples

Example 1

import { generate } from "https://deno.land/std@0.222.1/uuid/v5.ts";

const NAMESPACE_URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";

const uuid = await generate(NAMESPACE_URL, new TextEncoder().encode("python.org"));
uuid === "7af94e2b-4dd9-50f0-9c9a-8a48519bdef0" // true

Parameters

namespace: string

The namespace to use, encoded as a UUID.

data: Uint8Array

The data to hash to calculate the SHA-1 digest for the UUID.

Returns

Promise<string>