Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fastro/http/deps.ts>toHashString

Fast and simple web application framework for deno
Go to Latest
function toHashString
import { toHashString } from "https://deno.land/x/fastro@v0.77.3/http/deps.ts";

Converts a hash to a string with a given encoding.

Examples

Example 1

import { crypto } from "https://deno.land/std@0.224.0/crypto/crypto.ts";
import { toHashString } from "https://deno.land/std@0.224.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