Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Go to Latest
function toHashString
Deprecated
Deprecated

(will be removed after 0.209.0) Use std/encoding/hex.ts or std/encoding/base64.ts instead.

Converts a hash to a string with a given encoding.

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

Examples

Example 1

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

const hash = await crypto.subtle.digest("SHA-384", new TextEncoder().encode("You hear that Mr. Anderson?"));

// Hex encoding by default
console.log(toHashString(hash));

// Or with base64 encoding
console.log(toHashString(hash, "base64"));

Parameters

hash: ArrayBuffer
optional
encoding: "hex" | "base64" = [UNSUPPORTED]

Returns

string