0 dependency, pure TypesScript implementation of the AES block cipher and common modes of operation.
npm install aes-tsa modern port of AES-JS:
> A pure JavaScript implementation of the AES block cipher algorithm and all common modes of operation (CBC, CFB, CTR, ECB and OFB).
for proper documentation please check their README.md.
- enable three shaking
- it's rare that an app will use all this modes
- not every app needs encryption + decryption
- only half of the constants are needed on each direction
- a good replacement for libraries that import crypto-browserify on the browser.
- built-in typescript types
- don't roll your own crypto, especially don't touch Block directly.
- don't use ECB. don't reuse IVs.
- don't use this library, use SubtleCrypto, whenever possible.
ESM exports, listed by Common Mode Of Operation.
| * | Encryptor | Decryptor |
| :------ | -------------: | -------------: |
| Block | Encryptor | Decryptor |
| CBC | CBCEncryptor | CBCDecryptor |
| CFB | CFBEncryptor | CFBDecryptor |
| CTR | CTREncryptor | CTRDecryptor |
| ECB | ECBEncryptor | ECBDecryptor |
| OFB | OFBEncryptor | OFBDecryptor |
> replace ___ for the mode of operation.
>
> each mode has unique parameters, described by their types.
#### Encryptor
``javascript`
const encryptor = new ___Encryptor(key)
const ciphertext = encryptor.encrypt(plaintext)
#### Decryptor
`javascript`
const decryptor = new ___Decryptor(key)
const plaintext = decryptor.decrypt(ciphertext)
#### Encryptor + Decryptor
`javascript`
const mode = new ___(key)
const sametext = mode.decrypt(mode.encrypt(plaintext))
all crypto code and tests were taken directly from AES-JS, written by @ricmoo`.