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

openchain-encryption-nodejs-yxl

v1.2.1

Published

openchain-encryption-nodejs-yxl

Readme

openchain-encryption-nodejs

一个用于OpenChain区块链的加密工具库,提供密钥对生成、签名验证和密钥存储等功能。

安装

npm install openchain-encryption-nodejs-yxl-ts

功能特性

  • 密钥对生成和管理
  • 签名创建和验证
  • 密钥安全存储
  • 地址生成和验证

API使用说明

密钥对操作

const { keypair } = require('openchain-encryption-nodejs-yxl-ts');

// 创建新的密钥对
const keyPair = new keypair();

// 获取编码后的私钥
const encPrivateKey = keyPair.getEncPrivateKey();

// 获取编码后的公钥
const encPublicKey = keyPair.getEncPublicKey();

// 获取地址
const address = keyPair.getAddress();

// 从私钥获取公钥
const pubKey = keypair.getEncPublicKey(encPrivateKey);

// 从公钥获取地址
const addr = keypair.getAddress(encPublicKey);

// 验证私钥格式
const isValidPriv = keypair.checkEncPrivateKey(encPrivateKey);

// 验证公钥格式
const isValidPub = keypair.checkEncPublicKey(encPublicKey);

// 验证地址格式
const isValidAddr = keypair.checkAddress(address);

签名操作

const { signature } = require('openchain-encryption-nodejs-yxl-ts');

// 创建签名
const message = 'Hello OpenChain';
const sig = signature.sign(message, encPrivateKey);

// 验证签名
const isValid = signature.verify(message, sig, encPublicKey);

密钥存储

const { keystore } = require('openchain-encryption-nodejs-yxl-ts');

// 加密私钥
keystore.encrypt(encPrivateKey, 'your-password', (keystoreString) => {
    console.log('加密后的keystore:', keystoreString);
});

// 解密私钥
keystore.decrypt(keystoreString, 'your-password', (decryptedPrivateKey) => {
    console.log('解密后的私钥:', decryptedPrivateKey);
});

安全建议

  1. 请妥善保管私钥,不要泄露给他人
  2. 使用强密码保护keystore文件
  3. 定期备份重要的密钥数据
  4. 在进行签名操作时确保环境安全

错误处理

库中的大多数方法在遇到错误时会抛出异常,建议使用try-catch进行错误处理:

try {
    const keyPair = new keypair();
    const encPrivateKey = keyPair.getEncPrivateKey();
} catch (error) {
    console.error('操作失败:', error.message);
}

许可证

MIT