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

rsa-aes

v1.0.5

Published

针对前后端交互数据加密封装的rsa+aes的库 支持commonjs和es module

Downloads

3

Readme

rsa-aes

针对前后端交互数据加密封装的rsa+aes的库 支持commonjs和es module

  • 前端使用crypto-js + jsencrypt
  • node端使用crypto-js+node-rsa

包含9个常用方法:

  • getRsaKey(获取公钥私钥)

  • encryptRsa(rsa公钥加密)

  • decryptRsa(rsa私钥解密)

  • sign(rsa私钥加签)

  • verify(rsa公钥验签)

  • encryptRsaByPrivateKey(rsa私钥加密)

  • decryptRsaByPublicKey(rsa公钥解密)(由于jsencrypt不支持,所以客户端无此方法)

  • encryptAes(aes秘钥加密)

  • decryptAes(aes秘钥解密)

示例:

const crypt = require('rsa-aes')
/**
 * import crypt from 'rsa-aes'
 */
// 获取公钥私钥
let key = crypto.getRsaKey()
let secretKey = '1234567890abcdef'

console.log(key.publicKey)
console.log(key.privateKey)
// rsa公钥加密
let encryptRsa = crypto.encryptRsa(key.publicKey, secretKey)
console.log('encryptRsa', encryptRsa)
// rsa私钥解密
let decryptRsa = crypto.decryptRsa(key.privateKey, encryptRsa)
console.log('decryptRsa', decryptRsa)
// rsa 私钥加密
let encryptRsaByPrivateKey = crypto.encryptRsaByPrivateKey(key.privateKey, decryptRsa)
console.log('encryptRsaByPrivateKey', encryptRsaByPrivateKey)
// rsa 公钥解密  node端支持 客户端不支持
let decryptRsaByPublicKey = crypto.decryptRsaByPublicKey(key.publicKey, encryptRsaByPrivateKey)
console.log('decryptRsaByPublicKey', decryptRsaByPublicKey)
// rsa 私钥加签
let sign = crypto.sign(key.privateKey, secretKey, 'sha1') // ['md2', 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'ripemd160']
console.log('sign', sign)
// rsa 公钥验签
let verify = crypto.verify(key.publicKey, secretKey, sign, 'sha1')
console.log('verify', verify)
// 使用aes秘钥加密
let aesEncrypt = crypto.encryptAes(secretKey, "aa12345");
console.log("aesEncrypt", aesEncrypt);
// 使用aes秘钥解密
let aesDecrypt = crypto.decryptAes(secretKey, aesEncrypt);
console.log("aesDecrypt", aesDecrypt);