Skip to content

Documented example usage of Node API crypto.hash method throws TypeError as .hash() is undefined #987

Open
@noelforte

Description

@noelforte

Possibly related: denoland/deno#24945

Implementation and example usage of the .hash() method from node:crypto is a documented part of Deno's Node-compatible API.

However, attempting to run the following example throws an error:

import crypto from 'node:crypto';
import { Buffer } from 'node:buffer';

// Hashing a string and return the result as a hex-encoded string.
const string = 'Node.js';
// 10b3493287f831e81a438811a1ffba01f8cec4b7
console.log(crypto.hash('sha1', string));
~/Desktop => deno crypto-hash.ts
error: Uncaught (in promise) TypeError: crypto.hash is not a function
console.log(crypto.hash('sha1', string));
                   ^
    at file:///.../Desktop/crypto-hash.ts:7:20

Documented features should be supported or removed from the documentation until actually implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions