Socket
Book a DemoInstallSign in
Socket

long-encrypt

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

long-encrypt

jsencrypt的长数据加密方法

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

长字符串 rsa 加密解密方法

适用 jsencrypt、node-jsencrypt、wxmp-rsa 等包含 decrypt、encrypt 方法的加密库

安装

npm i long-encrypt

测试

npm run test

使用

引入

// nodejs
const {
    encryptData,
    decryptData
} = require('long-encrypt');

或者

// web
import {
    encryptData,
    decryptData
} from 'long-encrypt';

引入 jsencrypt

const JSEncrypt = require('jsencrypt');

或者

const JSEncrypt = require('node-jsencrypt');

创建实例

const encrypt = new JSEncrypt(); // 创建加密对象实例

const decrypt = new JSEncrypt(); // 创建解密对象实例

设置密钥

encrypt.setPublicKey(pubKey); //设置公钥
decrypt.setPrivateKey(privateKey); // 设置私钥

加密 encryptData(加密对象实例, "需要加密的字符串", [len=分段长度])

如果出现内容丢失,将 len 数字填大一些

encryptData(encrypt, "Long string", [len=32]);

=> "encryptStr1,encrypt2,..."

解密 decryptData(解密对象实例, "加密字符串");

decryptData(decrypt, "encryptStr1,encrypt2,...");

=> "Long string"

Keywords

node-jsencrypt

FAQs

Package last updated on 10 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.