1.0.0 • Published 1 year ago

@bitahon/crypto v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@bitahon/crypto

The library includes a crypto-provider for the Bitahon Protocol, encompassing core cryptographic interfaces and corresponding proxy classes.

Installation

General

To obtain the latest version, simply require the project using npm:

npm install @bitahon/crypto

Usage

Initialize the required crypto-provider implementing the ICryptoProvider interface. For example, in a web environment, you can utilize the package @bitahon/browser-crypto.

import {initCryptoProvider} from '@bitahon/crypto';

const provider = await import('@bitahon/browser-crypto');
initCryptoProvider(provider.default);

Once initialized with the chosen crypto-provider, you can proceed to utilize the methods provided by the ICryptoProvider interface.

import crypto from '@bitahon/crypto';

const data: Buffer = await crypto.randomBytes(64);
const hash: Buffer = crypto.sha256(data);

console.log(hash.toString('hex'));

API

Interfaces

Functions

License

MIT