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

easy-shamir-secret-sharing

v1.0.10

Published

easy-shamir-secret-sharing 是一個基於 Shamir 秘密分享方案的 TypeScript 庫。此庫允許將一個秘密分割成多個分享,並且需要一定數量的分享才能重建原始秘密。該庫提供了兩種編程風格:已實例化的物件風格和函數風格。

Downloads

52

Readme

Secrets Library

這個庫提供了一些方法來生成隨機數、分割秘密和重建秘密。 This library provides methods to generate random numbers, split secrets, and reconstruct secrets.

此庫是基於 shamir-secret-sharing 進行改善,以逹到更好用。 This library is based on improvement of shamir-secret-sharing.

此庫提供了兩種編程風格:已實例化的物件風格和函數風格。 This library provides two programming styles: an instantiated object style and a functional style.

安裝 / Installation

首先,確保你已經安裝了必要的依賴項: First, make sure you have installed the necessary dependencies:

npm i easy-shamir-secret-sharing

使用方法 / Usage

初始化 class Secrets 在使用 Secrets 類之前,需要先導入並初始化它:

Before using the Secrets class, you need to import and initialize it:

import { Secrets } from 'easy-shamir-secret-sharing';
//or
import { secrets } from 'easy-shamir-secret-sharing';

分割秘密 / Split Secret

使用 share 方法將秘密分割成多個分享: Use the share method to split a secret into multiple shares:

const secret = "your-secret";
const numShares = 10;
const threshold = 5;
const shares = secrets.share(secret, numShares, threshold);
console.log(shares);

重建秘密 / Combine Secret

使用 combine 方法重建秘密: Use the combine method to reconstruct the secret:

const combinedSecret = secrets.combine(shares);
console.log(combinedSecret);

示例代碼 / Example Code

please run in async function

import { Secrets, secrets as secretsInstance } from 'easy-shamir-secret-sharing'
async function main()
{
    const message = "這是兩段重要的訊息";
    let secrets : any = new Secrets(message, 4, 3); //in real, no any type used
    await secrets.executeShares();
    console.log("分割後的訊息段:", secrets.getSharesResult());
    await secrets.executeCombine(secrets.getSharesResult());
    console.log("還原後的密文:", secrets.getCombinedResult());
    //or
    console.log("另一種風格");
    secrets = secretsInstance
    const arr = await secrets.share(message, 4, 3)
    console.log("分割後的訊息段:", arr);
    const combined = await secrets.combine(arr)
    console.log("還原後的密文:", combined);
}
main()

貢獻 / Contributing

歡迎提交問題和請求,或創建拉取請求來改進此庫。

Issues and requests are welcome, or create a pull request to improve this library

授權 / License

此項目基於 MIT 許可證,詳情請參閱 LICENSE 文件。 This project is licensed under the MIT License. See the LICENSE file for details.

額外 / Remain

reference: The MIT License (MIT)

Author of the original secrets.js library: Alexander Stetsyuk, Glenn Rempe

Author of this fork and modifications: xva001

@license MIT https://www.npmjs.com/package/secrets.js-grempe

The Library used @license Apache-2.0 shamir-secret-sharing

no warranty is given that this code is correct, and the author cannot be held responsible for any errors or omissions. rewrite by xva001 purpose: use typescript to rewrite the secrets.js-grempe library to use on other project (xva001 fogx -- nuxt) with no dependency on node crypto library.

repo npm

更新 / Update detail

2025-01-27 change reference to shamir-secret-sharing

First aims is making this work, and let other easy to use.