@fyears/eme
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

EME

EME (Encrypt-Mix-Encrypt) wide-block encryption in TypeScript/JavaScript.

Intro

Pure and full TypeScript/JavaScript port of https://github.com/rfjakob/eme.

Almost line-to-line "translation", with all the ported test cases.

Usage

npm install @fyears/eme
import { EMECipher, AESCipherBlock } from "@fyears/eme"
import { deepStrictEqual } from "assert"
import { webcrypto } from "crypto"

(async function(){
    const key = new Uint8Array([
        0,1,2,3,4,5,6,7,
        8,9,10,11,12,13,14,15
    ]) // 16-byte Uint8Array the user provided for the AES part

    const tweak = new Uint8Array(16)
    webcrypto.getRandomValues(tweak)  // iv

    const input = new Uint8Array(64) // some Uint8Array the user provided
    webcrypto.getRandomValues(input)

    const bc = new AESCipherBlock(key)
    const eme = new EMECipher(bc)

    const output = await eme.encrypt(tweak, input)
    const inputBack = await eme.decrypt(tweak, output)

    deepStrictEqual(inputBack, input)
})()

Readme

Keywords

Package Sidebar

Install

npm i @fyears/eme

Weekly Downloads

13

Version

0.0.3

License

MIT

Unpacked Size

49.7 kB

Total Files

10

Last publish

Collaborators

  • fyears