1.0.5 • Published 7 months ago

pepto v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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

1.0.5

7 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.0.0

11 months ago