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

@dotatong/encrypt

v1.0.2

Published

A Javascript library to perform OpenSSL RSA Encryption, Decryption, and Key Generation. For Browser & Node

Readme

项目介绍

本项目是基于 travist/jsencrypt 改造的适用于 浏览器、服务器的 RSA加解密库。

使用说明

准备工作

使用 openssl 生成RSA密钥。

  • 在终端中输入以下命令,生成私钥。
openssl genrsa -out rsa_1024_priv.pem 1024
  • 继续输入以下命令,生成公钥。
openssl rsa -pubout -in rsa_1024_priv.pem -out rsa_1024_pub.pem

安装Encrypt

npm i @dotatong/encrypt

yarn add @dotatong/encrypt

使用Encrypt

  • 公钥加密、私钥解密
<!doctype html>
<html>
<head>
    <title>JavaScript RSA Encryption</title>
    <script src="dist/encrypt.js"></script>
</head>
<body>
<label for="prikey">Private Key</label><br />
<textarea id="prikey" rows="15" cols="65">-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQDlOJu6TyygqxfWT7eLtGDwajtNFOb9I5XRb6khyfD1Yt3YiCgQ
WMNW649887VGJiGr/L5i2osbl8C9+WJTeucF+S76xFxdU6jE0NQ+Z+zEdhUTooNR
aY5nZiu5PgDB0ED/ZKBUSLKL7eibMxZtMlUDHjm4gwQco1KRMDSmXSMkDwIDAQAB
AoGAfY9LpnuWK5Bs50UVep5c93SJdUi82u7yMx4iHFMc/Z2hfenfYEzu+57fI4fv
xTQ//5DbzRR/XKb8ulNv6+CHyPF31xk7YOBfkGI8qjLoq06V+FyBfDSwL8KbLyeH
m7KUZnLNQbk8yGLzB3iYKkRHlmUanQGaNMIJziWOkN+N9dECQQD0ONYRNZeuM8zd
8XJTSdcIX4a3gy3GGCJxOzv16XHxD03GW6UNLmfPwenKu+cdrQeaqEixrCejXdAF
z/7+BSMpAkEA8EaSOeP5Xr3ZrbiKzi6TGMwHMvC7HdJxaBJbVRfApFrE0/mPwmP5
rN7QwjrMY+0+AbXcm8mRQyQ1+IGEembsdwJBAN6az8Rv7QnD/YBvi52POIlRSSIM
V7SwWvSK4WSMnGb1ZBbhgdg57DXaspcwHsFV7hByQ5BvMtIduHcT14ECfcECQATe
aTgjFnqE/lQ22Rk0eGaYO80cc643BXVGafNfd9fcvwBMnk0iGX0XRsOozVt5Azil
psLBYuApa66NcVHJpCECQQDTjI2AQhFc1yRnCU/YgDnSpJVm1nASoRUnU8Jfm3Oz
uku7JUXcVpt08DFSceCEX9unCuMcT72rAQlLpdZir876
-----END RSA PRIVATE KEY-----</textarea><br />
<label for="pubkey">Public Key</label><br />
<textarea id="pubkey" rows="15" cols="65">-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDlOJu6TyygqxfWT7eLtGDwajtN
FOb9I5XRb6khyfD1Yt3YiCgQWMNW649887VGJiGr/L5i2osbl8C9+WJTeucF+S76
xFxdU6jE0NQ+Z+zEdhUTooNRaY5nZiu5PgDB0ED/ZKBUSLKL7eibMxZtMlUDHjm4
gwQco1KRMDSmXSMkDwIDAQAB
-----END PUBLIC KEY-----</textarea><br />
<label for="input">Text to encrypt:</label><br />
<textarea id="input" name="input" type="text" rows=4 cols=70>This is a test!</textarea><br />
<input id="testme" type="button" value="Test Me!!!" /><br />
<script type="text/javascript">
document.getElementById("testme").addEventListener("click", () => {
    const prikey = document.getElementById('prikey').value;
    const pubkey = document.getElementById('pubkey').value;
    const input = document.getElementById('input').value;

    // Encrypt with the public key...
    let encrypt = new Encrypt();
    encrypt.setPublicKey(pubkey);
    let encrypted = encrypt.encrypt(input);

    // Decrypt with the private key...
    let decrypt = new Encrypt();
    decrypt.setPrivateKey(prikey);
    let decrypted = decrypt.decrypt(encrypted);

    // Now a simple check to see if the round-trip worked.
    if (decrypted === input) {
        alert("解密成功!!!");
    } else {
        alert("解密失败...");
    }
});
</script>
</body>
</html>
  • 私钥签名、公钥验证
import { Encrypt } from "@dotatong/encrypt";

const prikey = document.getElementById("prikey").value;
const pubkey = document.getElementById("pubkey").value;
const input = document.getElementById("input").value;

// Sign with the private key...
var sign = new Encrypt();
sign.setPrivateKey(prikey);
var signature = sign.sign(input, CryptoJS.SHA256, "sha256");

// Verify with the public key...
var verify = new Encrypt();
verify.setPublicKey(pubkey);
var verified = verify.verify(input, signature, CryptoJS.SHA256);

// Now a simple check to see if the round-trip worked.
if (verified) {
    alert("签名验证通过!!!");
} else {
    alert("签名验证失败...");
}