encrypt-kit
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

encrypt-kit 使用指南 1.0.2

npm

npm install encrypt-kit

0 EncryptInterface 加密接口

export interface EncryptInterface {
    // 必填 公钥
    publicKey: string | number;
    // 私钥
    privateKey?: string | number;
    // 必填 加密实例
    jsEncryptInstance: any;


    /**
     * 加密
     * @param plaintext:明文
     */
    encryptData(plaintext): string

    /**
     * 解密
     * @param ciphertext:密文
     * @param privateKey:私钥
     */
    decryptData(ciphertext,privateKey?): string
}

1 JsSm4Client 国密4 加密,解密

封装了JsSm4,

配置参数描述 key : 秘钥

  • 加密方法

  • @param plaintext

  • encryptData( plaintext:string): string

  • 解密方法

  • @param ciphertext

  • decryptData(ciphertext:string): string

// 引入

import {JsSm4Client} from 'encrypt-kit'

let jsSm4Client = new JsSm4Client('youKey')

let a = "1232123"

console.log(jsSm4Client.decryptData(jsSm4Client.encryptData(a))); // 1232123

2 RsaClient rsa 加密,解密

封装了RsaClient,

配置参数描述 key : 秘钥

  • 加密方法

  • @param plaintext

  • encryptData( plaintext:string): string

  • 解密方法

  • @param ciphertext

  • decryptData(ciphertext:string): string

// 引入

import {RsaClient} from 'encrypt-kit'

const publickKey = 'youPublickKey'
const privateKey = 'youPrivateKey'

let rsaClient = new RsaClient(key)

let a = "1232123"

console.log(rsaClient.decryptData(rsaClient.encryptData(a))); // 1232123

Package Sidebar

Install

npm i encrypt-kit

Weekly Downloads

2

Version

1.0.2

License

none

Unpacked Size

5.98 kB

Total Files

7

Last publish

Collaborators

  • ahrimansource