matcrypt

WebCrypto wrapper that makes AES, RSA and hashing easy.

Usage no npm install needed!

<script type="module">
  import matcrypt from 'https://cdn.skypack.dev/matcrypt';
</script>

README

matcrypt

workflow npm npm NPM

Disclaimer

While I've made sure to adhere to all best practices when it comes to AES and WebCrypto, I am not a cryptography professional. This code is not audited. I use this in production, but you should never blindly trust any cryptographic code from the internet.

This library only works in browser environments that support WebCrypto.

About

WebCrypto wrapper that makes AES easy.

This library supports

(AES-256)

  • Random key generation
  • String encryption/decryption (ciphertext is base64 encoded as well for easy storage)
  • Binary data encryption/decryption

(The library handles IV randomization and storage.)

(SHA-512)

  • Compute a base64-encoded hash of binary data

(RSA-OAEP-2048)

  • Random key pair generation
  • String encryption/decryption (ciphertext is base64 encoded as well for easy storage)
  • Binary data encryption/decryption

(The library handles AES secret randomization and storage.)

Code example

import { AES } from 'matcrypt';

async function example() {
  let key = await AES.randomKey();
  let ciphertext = await AES.encryptString(key, testString);
  let plaintext = await AES.decryptString(key, ciphertext);
}