Skip to main content
Module

std/crypto/_util.ts>createHash

Deno standard library
Go to Latest
function createHash
import { createHash } from "https://deno.land/std@0.174.0/crypto/_util.ts";

Creates a hash from a string or binary data, taking care of the boilerplate required for most cases.

Examples

import { crypto } from "https://deno.land/std@0.174.0/crypto/crypto.ts";

const encoder = new TextEncoder();

const hash = await crypto.subtle.digest("SHA-1", encoder.encode("Hello, world!"));
import { createHash } from "https://deno.land/std@0.174.0/crypto/_util.ts";

const hash = await createHash("SHA-1", "Hello, world!");

Parameters

algorithm: DigestAlgorithm
data:
| string
| AsyncIterable<BufferSource>
| Iterable<BufferSource>

Returns

Promise<ArrayBuffer>