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

x/ayonli_jsext/hash.ts>sha256

A JavaScript extension package for building strong and modern applications.
Latest
function sha256
import { sha256 } from "https://deno.land/x/ayonli_jsext@v0.9.72/hash.ts";

Calculates the SHA-256 hash of the given data.

Examples

Example 1

import { sha256 } from "@ayonli/jsext/hash";

const buffer = await sha256("Hello, World!");
console.log(buffer); // ArrayBuffer(32) { ... }

Returns

Promise<ArrayBuffer>

Examples

Example 1

import { sha256 } from "@ayonli/jsext/hash";

const hex = await sha256("Hello, World!", "hex");
console.log(hex); // dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f

const base64 = await sha256("Hello, World!", "base64");
console.log(base64); // 3/1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8=

Parameters

encoding: "hex" | "base64"

Returns

Promise<string>