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

tea-encrypt

v1.4.4

Published

>项目勿删,desktop 有引用该项目

Downloads

7

Readme

项目勿删,desktop 有引用该项目

C 加密扩展

利用 node-gyp 封装由 c 语言写的加密模块,生成 .node 文件供 nodejs 调用。

配置

node-gyp 项目下需要有 binding.gyp 作为配置。配置中最重要是定义原生模块: "targets": [{ "target_name": "addon1", "sources": [ "1/addon.cc", "1/myobject.cc" ] }] 上面配置的含义是模块名为 addon1,模块源码包括 "1/addon.cc", "1/myobject.cc"。(模块中所有引入的文件都要写上,不单单是入口文件)。

小记: node-gyp 是 c++ 编译器,如果待编译文件中有 c 文件,需要在 c++ 文件的引入头中用 extern "C"{} 将引入的 c 文件包裹起来。

执行命令

  • node-gyp configure:项目构建前先执行这个命令,node-gyp 会根据系统下载对应的编译环境和所需的头文件;
  • node-gyp build:项目开始构建生成对应系统的二进制文件,编译出来的二进制文件生成在 build/Release 文件夹中;
  • node-gyp clean:删除 build 文件夹;
  • node-gyp rebuild:按 clean - configure - build 执行一遍,重新编译。

进阶

经过上面方式编译出来的二进制文件要拿到 electron 中使用可能会报下面的错误:

NODE_MODULE_VERSION 64. This version of Node.js requires
NODE_MODULE_VERSION 69. Please try re-compiling or re-installing

这是因为在系统中安装的 nodejs 与 electron 的 NODE_MODULE_VERSION 不一样。node 与 electron 版本对应的 NODE_MODULE_VERSION 可通过 node-abi 查询。

要解决无法编译出适合指定版本 electron 的扩展,可以用下面两种方法:

  1. 在 node-gyp 命令中指定编译的 electron 版本:

    node-gyp build --target=4.1.3 --arch=x64 --dist-url=https://atom.io/download/ato-shell
    --target 指定 electron 版本
    --arch 设置模块为适应64位或32位操作系统而编译
    --dist-url 指定下载 electron 的 headers 的地址

    但这种方法有个缺陷,只能为每一个 electron 每一种操作系统去修改命令,这时就需要第二种方法。

  2. 安装 electron-rebuild,只需直接执行 electron-rebuild -v=4.1.3 -f 就能编译出符合当前系统的指定 electron 版本的二进制文件,如果你是在 electron 项目中执行 electron-rebuild,甚至不需要指定 electron 版本。

很明显第二种方式更具有兼容性。