npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@linker-design/crypto

v0.3.1

Published

A lightweight crypto library which could run on `browser`, `node`, `java(jvm)`, `dotnet` platform base on `openssl libcrypto library`.

Downloads

83

Readme

@LinkerDesign/Crypto

A lightweight crypto library which could run on browser, node, java(jvm), dotnet platform base on openssl libcrypto library.

  • browser, node package

    • we use webassembly technology to port and encapsulate the native c library(openssl libcrypto). you could access the package here
  • dotnet package

    • we use p/invoke technology to port and encapsulate the native c library(openssl libcrypto) . you could access the package here
  • java(jvm) package

    • we use jni(java native interface) technology to port and encapsulate the native c library(openssl libcrypto). you could access the package here

Features

  1. Symmetric Encryt Decrypt
  • AES-CBC
  • AES-CTR
  1. Message Digest
  • Sha1
  • Sha256
  • Sha384
  • Sha512
  • Md5
  • Md5Sha1
  1. Big file(like 100G) message digest Support

more features will come soon!

Setup

npm i -S @linker-design/crypto

usages

  1. AES Uint8Array or Blob

We can use aes-cbc to encrypt or decrypt an arraybuffer

import { AES } from `@linker-design/crypto`;

const aes = new AES();

// key is a base64 string which can be geted from backend server or generate by aes
const key = await aes.generateKey();

// iv is a base64 string which can geted from backend server or generate by aes
const iv = await aes.generateIV();

// clearText is an arraybuffer which can be readed from a file or network
const file = new Uint8Array([1,2,3,5]);

// cipher is the encrypted arraybuffer
const cipher = await aes.encrypt(key, iv, file);

// after all, we can decrypt the cipher with the same key, iv;
// as a result, file1 has the same content of file.
const file1 = await aes.decrypt(key, iv, cipher);
  1. AES String

We can use AES-CBC to encryt a string who's encoding is utf8 to a base64 string.

Additional, we can AES-CBC to decrypt a base64 string to it's original utf8 string

import { AES } from `@linker-design/crypto`;

const aes = new AES();

// key is a base64 string which can be geted from backend server or generate by aes
const key = await aes.generateKey();

// iv is a base64 string which can geted from backend server or generate by aes
const iv = await aes.generateIV();

// data is a utf8 string
const text = "hello world";

// cipher is a base64 string
const cipher = await aes.encrypt(key, iv, text, 'utf8');

// we can decrypt the cipher like this.
// after that, text1 is the same as text;
const text1 = await aes.decrypt(key, iv, cipher, undefined, 'utf8');
  1. Message Digest

support regular message digest algorith, like sha1, sha256, md5 etc...

import { Sha1, Sha256, Sha384, Sha512, Md5, Md5Sha1 } from '@linker-design/crypto';

const msg = '《青溪》是唐代诗人王维创作的一首五言古诗。此诗描写了一条青溪的幽秀景色,诗人用多彩的画笔,绘出青溪流经不同地方时呈现的不同画面。其中“声喧乱石中,色静深松里”两句,以喧响的声音和幽冷的色调形成闹与静的强烈对比,如同一幅“有声画”。诗的末四句写出诗人心境的闲谈正如清川的闲淡,把自己的精神和自然的精神融和起来,意味隽永。全诗自然清淡素雅,写景抒情皆轻轻松松,然而韵味却隽永醇厚。诗人笔下的青溪是喧闹与沉郁的统一,活泼与安详的揉合,幽深与素静的融和。';

// sha1
const sha1 = new Sha1();
let hash = await sha1.digest(msg, 'utf8', 'base64');
console.log(hash);

// sha256
const sha256 = new Sha256();
hash = await sha256.digest(msg, 'utf8', 'base64');
console.log(hash);

// sha384
const sha384 = new Sha384();
hash = await sha384.digest(msg, 'utf8', 'base64');
console.log(hash);

// sha512
const sha512 = new Sha512();
hash = await sha512.digest(msg, 'utf8', 'base64');
console.log(hash);

// md5
const md5 = new Md5();
hash = await md5.digest(msg, 'utf8', 'base64');
console.log(hash);

// md5sha1
const md5Sha1 = new Md5Sha1();
hash = await md5Sha1.digest(msg, 'utf8', 'base64');
console.log(hash);