@bonniernews/rolling-hash

中文文档
2.0.0发布于 2026/06/02MITTypeScriptESM + CJS零依赖近 30 天下载 2942

当吊销身份证时 你可能不希望它保持不变 永远 所以这个库通过滚动解决了这个问题.

中文使用文档
文档目录5 节
  1. 使用量
  2. 安装
  3. 所需资源
  4. 运行
  5. 免责声明

滚出大麻

当吊销身份证时 你可能不希望它保持不变 永远 所以这个库通过滚动解决了这个问题.

滚动在固定的日期间隔进行,然后给你新的ID来使用!

这个滚动散列库应该能够与各种加密库合作,并且仍然给出有效的滚动ID.

使用量

安装

npm install @bonniernews/rolling-hash

所需资源

节点.js20或更新.

运行

任何密码库都简单易用.

简单地输入给定的散列函数, 到 Base64 函数和 HexFunction 并取回一个滚动的 Hash .

带有自动加密库的示例 :

import rollingHash from "@bonniernews/rolling-hash";
import crypto from "node:crypto";

async function hashFunction(str) {
  const arrayBuffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(str));

  return Array.from(new Uint8Array(arrayBuffer));
}

function toBase64Function(hash) {
  return Buffer.from(hash).toString("base64");
}

function toHexFunction(hash) {
  return hash.map((b) => b.toString(16).padStart(2, "0")).join("");
}

const rolledHash = await rollingHash("foobar", { hashFunction, toBase64Function, toHexFunction });

// use rolledHash as you want

使用同步加密库的例子 :

import rollingHash from "@bonniernews/rolling-hash";
import cryptoJs from "crypto-js";

function hashFunction(str) {
  return cryptoJs.SHA256(str);
}

function toBase64Function(hash) {
  return hash.toString(cryptoJs.enc.Base64);
}

function toHexFunction(hash) {
  return hash.toString(cryptoJs.enc.Hex);
}

const rolledHash = rollingHash("foobar", { hashFunction, toBase64Function, toHexFunction });

// use rolledHash as you want

如果使用普通JS:

const { default: rollingHash } = require("@bonniernews/rolling-hash");

免责声明

散列的滚动时间可能改变.

我们使用 Date 类来处理散列, 如果修改了它的话, 我们无法保证这将100%的时间工作 .

版本与发布记录

@bonniernews/rolling-hash 共发布 4 个版本,首次发布于 2023/10/10;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.0.0latest2026/06/025 个月前
1.0.22023/10/103 年前
1.0.12023/10/103 年前
1.0.02023/10/103 年前

关于 @bonniernews/rolling-hash 的常见问题

@bonniernews/rolling-hash 是什么?

当吊销身份证时 你可能不希望它保持不变 永远 所以这个库通过滚动解决了这个问题.

如何安装 @bonniernews/rolling-hash?

在项目目录运行 npm install @bonniernews/rolling-hash,或使用 pnpm add / yarn add / bun add。

@bonniernews/rolling-hash 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@bonniernews/rolling-hash 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@bonniernews/rolling-hash 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bonniernews/rolling-hash 可以商用吗?

@bonniernews/rolling-hash 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bonniernews/rolling-hash 的下载量有多少?

根据 npm 官方下载统计,@bonniernews/rolling-hash 在 2026/10/09 – 2026/11/07 这 30 天内被下载 2,942 次,日均约 98 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@bonniernews/rolling-hash 还在维护吗?

最新版本 2.0.0 发布于 2026/06/02(5 个月前);至今共发布 4 个版本,其中过去 12 个月发布了 1 个;首次发布于 2023/10/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。