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 🙏

© 2026 – Pkg Stats / Ryan Hefner

lazy-kit-crypto

v1.0.2

Published

> A customized crypto toolkit.

Downloads

4

Readme

lazy-kit-crypto

A customized crypto toolkit.

Functions

/**
 * 获取指定长度的随机整数
 * @param length 长度, 默认4
 * @returns 随机数
 */
function randomInt(length?: number): number;

/**
 * 返回一个基于日期+随机整数的UUID
 * @param extraLength 默认是20位长度, 如果需要更长, 可以设置增加的长度, 默认0
 * @returns UUID
 */
function dateUUID(extraLength?: number): string;

/**
 * 获取一个nodejs的UUID, v4版本
 * @param slash 默认true, 是否带有“-”
 * @returns 
 */
function v4UUID(slash?:boolean): string;

/**
MD5 (Message Digest 5):生成的哈希值长度为 128 位,等于 16 字符。
SHA-1 (Secure Hash Algorithm 1):生成的哈希值长度为 160 位,等于 20 字符。
SHA-256 (Secure Hash Algorithm 256):生成的哈希值长度为 256 位,等于 32 字符。
SHA-512 (Secure Hash Algorithm 512):生成的哈希值长度为 512 位,等于 64 字符。
SHA-3 (Secure Hash Algorithm 3):SHA-3 可以生成不同长度的哈希值,例如 SHA-3-256 生成 256 位哈希值,SHA-3-512 生成 512 位哈希值。
*/
type HashAlgorithm = "md5"|"sha1"|"sha256"|"sha512"|"sha3-256"|"sha3-512";
type HashEncoding = "hex"|"base64";
/**
 * 获取文本的摘要
 * @param input 输入的文本
 * @param options 参数 {
 * algorithm: "md5"|"sha1"|"sha256"|"sha512"|"sha3-256"|"sha3-512"
 * encoding: "hex"|"base64"
 * }
 * @returns 
 */
function hash(input: any, options?: {
  algorithm: HashAlgorithm; // 哈希算法,例如 'md5', 'sha256' 等
  encoding: HashEncoding; // 输出编码,例如 'hex', 'base64' 等
}): string;

/**
 * 加密参数
 */
interface EncryptOptions {
  keyLengthBytes: number; // 密钥字节长度
  encoding: "hex"|"base64"; // 编码方式,例如 'hex', 'base64' 等
  algorithm: string; // 加密算法,例如 'aes-192-cbc'
  inputEncoding: BufferEncoding; // 输入字符编码,例如 'utf8'
}

/**
 * 生成随机盐值
 * @param length 长度 默认16
 * @returns 
 */
function generateRandomSalt(length?: number): string;

/**
 * 对称加密函数
 * @param data 原文数据
 * @param secretKey 密钥字符串
 * @param salt 加盐
 * @param options 参数 EncryptionOptions
 * @returns 
 */
function encrypt(data: string, secretKey: string, salt: string, options: EncryptOptions): string;

/**
 * 对称解密函数
 * @param encryptedData 密文数据
 * @param secretKey 密钥字符串
 * @param salt 加盐
 * @param options 参数 EncryptionOptions
 * @returns 
 */
function decrypt(encryptedData: string, secretKey: string, salt: string, options: EncryptOptions): string;

/**
 * 生成 RSA 密钥对
 * @param options {
 * { 
    modulusLength=4096, 
    publicKeyEncoding={
      type: 'spki',
      format: 'pem',
    }, privateKeyEncoding = {
      type: 'pkcs8',
      format: 'pem',
    } 
  }
* @returns 
*/
function generateKeyPair(options?:any): { publicKey:string; privateKey:string; };

/**
 * 加密函数:使用公钥加密数据
 * @param data 原文
 * @param publicKey 加密私钥
 * @param dataEncoding 原文编码, 默认"utf8"
 * @param encryptEncoding 密文编码, 默认"base64"
 * @returns 密文
 */
function encryptWithPublicKey(data: string, publicKey: string, dataEncoding?:any, encryptEncoding?:any): string;

/**
 * 解密函数:使用私钥解密数据
 * @param encryptedData 密文
 * @param privateKey 解密私钥
 * @param dataEncoding 原文编码, 默认"utf8"
 * @param encryptEncoding 密文编码, 默认"base64"
 * @returns 原文
 */
function decryptWithPrivateKey(encryptedData: string, privateKey: string, dataEncoding?:any, encryptEncoding?:any): string;