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

wecipher

v1.0.10

Published

微信小程序加密工具库,基于 ECIES (ECDH + AES-GCM) 方案

Readme

WeCipher

微信小程序加密工具库,基于 ECIES (ECDH + AES-GCM) 方案。

npm version npm downloads npm license

English | 中文

安装

npm install wecipher

主要 API

密钥生成

  • generateP256KeyPair() - 生成 P-256 密钥对
  • generateAES256Key() - 生成 AES-256 密钥

加密解密

  • encryptAESGCM(plaintext, key) - AES-GCM 加密(返回 EncryptedData 对象)
  • decryptAESGCM(encryptedData, key) - AES-GCM 解密(接收 EncryptedData 对象)
  • encryptWithAESGCM(plainText, aesKey) - AES-GCM 加密(返回 Base64 字符串)
  • decryptWithAESGCM(cipherTextBase64, aesKey) - AES-GCM 解密(接收 Base64 字符串)
  • encryptAESKeyCompat(aesKey, serverPubKey) - ECIES 加密(兼容 Bouncy Castle)

密钥交换

  • deriveSharedSecret(privateKey, publicKey) - 派生共享密钥
  • deriveAESKey(sharedSecret) - 派生 AES 密钥

载荷加密

  • clientEncryptField(plaintext, serverPublicKey, clientKeyPair) - 客户端加密
  • clientDecryptField(encryptedData, serverPublicKey, clientPrivateKey) - 客户端解密

工具函数

  • bytesToBase64(bytes) / base64ToBytes(base64) - Base64 转换
  • jwkToPublicKey(jwk) - JWK 格式转换
  • extractPublicKeyFromDERBase64(derBase64) - DER 格式解析

微信小程序

  • initWxSecureRandomCache(size?) - 初始化安全随机数缓存(必须先调用),默认128字节,可自定义大小
  • setupWxPolyfills() - 设置微信小程序环境补丁,包括 TextEncoder/TextDecoder、crypto.getRandomValues、wx.getSecureRandomValuesSync(需先调用 initWxSecureRandomCache)
  • generateAndCacheSecureRandomBytes(size?) - 生成并缓存安全随机数,默认128字节,使用 HKDF-SHA256 确保密码学安全性
  • getSecureRandomValuesSync(length) - 同步获取指定长度的安全随机数
  • wxGetSecureRandomValuesAsync(length) - 异步获取随机数
  • isCacheInitialized() - 检查缓存是否已初始化
  • resetSecureRandomCache() - 重置缓存(用于测试)

License

ISC