pepto
    Preparing search index...

    pepto

    pepto

    NPM

    NPM version build codecov

    Generate a hex string digest from a given message. See SubtleCrypto.digest() and Replit demo.

    import { digest } from 'pepto';

    await digest('SHA-256', 'Hello, World!');

    NPM:

    npm install pepto
    

    Yarn:

    yarn add pepto
    

    Import ES Modules:

    import { digest } from 'pepto';
    

    Require with CommonJS:

    const { digest } = require('pepto');
    

    Hash message with SHA-1 algorithm:

    await digest('SHA-1', 'message');
    

    Hash message with SHA-256 algorithm:

    await digest('SHA-256', 'message');
    

    Hash message with SHA-384 algorithm:

    await digest('SHA-384', 'message');
    

    Hash message with SHA-512 algorithm:

    await digest('SHA-512', 'message');
    

    Use promise instead of async-await:

    digest('SHA-512', 'message').then((hex) => console.log(hex));
    

    If you get this error in your Jest tests, then add the following to your setupTests.ts:

    import { TextEncoder } from 'util';
    window.TextEncoder = TextEncoder;

    Or add the following to your setupTests.js:

    const { TextEncoder } = require('util');
    window.TextEncoder = TextEncoder;

    MIT