pepto
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

pepto

NPM

NPM version build codecov

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

Quick Start

import { digest } from 'pepto';

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

Installation

NPM:

npm install pepto

Yarn:

yarn add pepto

Usage

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));

FAQ

ReferenceError: TextEncoder is not defined

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;

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i pepto

Weekly Downloads

131

Version

1.0.5

License

MIT

Unpacked Size

16.6 kB

Total Files

22

Last publish

Collaborators

  • remarkablemark