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

0.1.1119 • Public • Published

$mol_crypto

Simple API for effective cross platform cryptography with minimal extra size.

(a)Symmetric Encryption, Signing, Hashing

const Alice = await $mol_crypto_key_private.generate() // 96 B
const Bella = await $mol_crypto_key_private.generate() // 96 B

const secret = await $mol_crypto_secret.derive(
	Alice.toString(), // 96 -> 129 B
	Bella.public().toString() // 64 -> 86 B
)

const data = new Uint8Array([ 1, 2, 3 ]) // 3 B
const salt = $mol_crypto_salt() // 12 B

const closed = await secret.encrypt( data, salt ) // 3+4 B
const digest = $mol_crypto_hash( closed ) // 20 B
const sign = await Alice.sign( digest ) // 64 B

const verified = await Alice.public().verify( digest, sign )
const opened = await secret.decrypt( closed, salt ) // 3 B

Authentication

// Returns authenticated secret key using WebAuthn
const Alice = await $mol_crypto_secret_id()

Usage from NPM

npm install mol_crypto_lib

import { $mol_crypto_salt } from 'mol_crypto_lib'

Package Sidebar

Install

npm i mol_crypto_lib

Weekly Downloads

399

Version

0.1.1119

License

none

Unpacked Size

882 kB

Total Files

26

Last publish

Collaborators

  • jin