@kaffee/espresso
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

@kaffee/espresso

A based TypeScript crypto library, tree shaking support

Installation

Install with npm

  npm install --dev @kaffee/espresso

Install with yarn

  yarn add --dev @kaffee/espresso

Install with pnpm

  pnpm add -D @kaffee/espresso

Support List

Hash

  • md4
  • md5
  • pbkdf2
  • ripemd128
  • ripemd160
  • ripemd256
  • ripemd320
  • sha1
  • sha3
  • sha224
  • sha256
  • sha384
  • sha512

Hmac Hash

  • md4
  • md5
  • pbkdf2
  • ripemd128
  • ripemd160
  • ripemd256
  • ripemd320
  • sha1
  • sha3
  • sha224
  • sha256
  • sha384
  • sha512

Block Cipher

  • AES
  • DES
  • Triple DES

Stream Cipher

but is not support

  • SEED
  • Rabbit
  • Rabbit Legacy
  • RC4

Example

Hash Example

import { MD5 } from "@kaffee/espresso";

const hash = MD5("LIBAOBAO").toString();

Block Cipher Example

import { AES, enc, RIPEMD160, mode, pad } from "@kaffee/espresso";

function AESEncrypt(text: string, keyStr: string, ivStr: string): string {
  const key = RIPEMD160(keyStr).toString().slice(0, 16);
  const iv = enc.Utf8.parse(ivStr);
  return AES.encrypt(text, Utf8.parse(key), {
    iv,
    mode: mode.CBC,
    padding: pad.PKCS7
  }).toString();
}

function AESDecrypt(text: string, key: string, ivStr: string): string {
  const iv = enc.Utf8.parse(ivStr);
  return AES.decrypt(text, key, {
    iv,
    mode: mode.CBC,
    padding: pad.PKCS7
  }).toString(enc.Utf8);
}

Other

tree shaking

License

GPL

Contributors

Readme

Keywords

none

Package Sidebar

Install

npm i @kaffee/espresso

Weekly Downloads

0

Version

1.0.6

License

GPLV3

Unpacked Size

729 kB

Total Files

516

Last publish

Collaborators

  • muromi