<commit_before># $mol_crypto

Simple API for effective cross platform cryptography.

## Symmetric encoding

```typescript
// Any DataView or ArrayBuffer
const data = new Uint8Array([1,2,3])

// Should be unique for every encryption
const salt = $mol_crypto_salt()

// Generates secret key
const Alice = await $mol_crypto_secret.generate()

// Serialize secret key to ArrayBuffer
const key = await Alice.serial()

// Reuse secret key from ArrayBuffer
const Bob = await $mol_crypto_secret.from( key )

// Use secret key and salt to encrypt data
const closed = await Alice.encrypt( data, salt )

// Use secret key and salt to decrypt data
const opened = await Bob.decrypt( closed, salt )
```

## Asymmetric encoding

```typescript
// Any DataView or ArrayBuffer
const data = new Uint8Array([1,2,3])

// Generates private-public key pair
const pair = await $mol_crypto_cipher_pair()

// Serialize keys to ArrayBuffer
const key_public = await pair.public.serial()
const key_private = await pair.private.serial()

// Reuse keys from ArrayBuffer
const Alice = await $mol_crypto_cipher_public.from( key_public )
const Bob = await $mol_crypto_cipher_private.from( key_private )

// Use public key to encrypt data
const closed = await Alice.encrypt( data )

// Use private key to decrypt data
const opened = await Bob.decrypt( closed )
```

## Asymmetric signing

```typescript
// Any DataView or ArrayBuffer
const data = new Uint8Array([1,2,3])

// Generates private-public key pair
const pair = await $mol_crypto_auditor_pair()

// Serialize keys to ArrayBuffer
const key_public = await pair.public.serial()
const key_private = await pair.private.serial()

// Reuse keys from ArrayBuffer
const Alice = await $mol_crypto_auditor_public.from( key_public )
const Bob = await $mol_crypto_auditor_private.from( key_private )

// Make sign for data
const sign = await Alice.sign( data )

// Use sign to verify data
const  = await Bob.verify( data, sign )
```<commit_msg>$mol_crypto: + npm usage + bundlephobia<commit_after># $mol_crypto

Simple API for effective cross platform cryptography.

## Symmetric encoding

```typescript
// Any DataView or ArrayBuffer
const data = new Uint8Array([1,2,3])

// Should be unique for every encryption
const salt = $mol_crypto_salt()

// Generates secret key
const Alice = await $mol_crypto_secret.generate()

// Serialize secret key to ArrayBuffer
const key = await Alice.serial()

// Reuse secret key from ArrayBuffer
const Bob = await $mol_crypto_secret.from( key )

// Use secret key and salt to encrypt data
const closed = await Alice.encrypt( data, salt )

// Use secret key and salt to decrypt data
const opened = await Bob.decrypt( closed, salt )
```

## Asymmetric encoding

```typescript
// Any DataView or ArrayBuffer
const data = new Uint8Array([1,2,3])

// Generates private-public key pair
const pair = await $mol_crypto_cipher_pair()

// Serialize keys to ArrayBuffer
const key_public = await pair.public.serial()
const key_private = await pair.private.serial()

// Reuse keys from ArrayBuffer
const Alice = await $mol_crypto_cipher_public.from( key_public )
const Bob = await $mol_crypto_cipher_private.from( key_private )

// Use public key to encrypt data
const closed = await Alice.encrypt( data )

// Use private key to decrypt data
const opened = await Bob.decrypt( closed )
```

## Asymmetric signing

```typescript
// Any DataView or ArrayBuffer
const data = new Uint8Array([1,2,3])

// Generates private-public key pair
const pair = await $mol_crypto_auditor_pair()

// Serialize keys to ArrayBuffer
const key_public = await pair.public.serial()
const key_private = await pair.private.serial()

// Reuse keys from ArrayBuffer
const Alice = await $mol_crypto_auditor_public.from( key_public )
const Bob = await $mol_crypto_auditor_private.from( key_private )

// Make sign for data
const sign = await Alice.sign( data )

// Use sign to verify data
const  = await Bob.verify( data, sign )
```

# Usage from NPM

```
npm install mol_crypto_lib
```

[![](https://badgen.net/bundlephobia/minzip/mol_crypto_lib)](https://bundlephobia.com/package/mol_crypto_lib)

```javascript
import { $mol_crypto_salt } from 'mol_crypto_lib'
```
{'fraction_non_alphanumeric': 0.0987535953978907, 'fraction_numerical': 0.005752636625119847, 'mean_word_length': 4.527152317880795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5675950', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1240, 'n_words': 443}