@wecom/crypto
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@wecom/crypto

企业微信加解密库,详见企业微信 API 文档 加解密方案说明JS-SDK使用权限签名算法

使用

# with npm
npm install @wecom/crypto
# with yarn
yarn add @wecom/crypto

API

获取消息体签名

import { getSignature } from '@wecom/crypto';

const signature = getSignature(token, timestamp, nonce, ciphered);

expect(signature).toEqual(query.signature);

解密消息

import { decrypt } from '@wecom/crypto';

const { message, id } = decrypt(encodingAESKey, ciphered);

console.log({ message, id });

加密消息

import { encrypt } from '@wecom/crypto';

const ciphered = encrypt(encodingAESKey, message, id);

console.log(ciphered);

获取 JS-SDK 签名

import { getJsApiSignature } from '@wecom/crypto'

const { timestamp, nonceStr, signature } = getJsApiSignature({ url, ticket });

console.log({ timestamp, nonceStr, signature });

Dependents (14)

Package Sidebar

Install

npm i @wecom/crypto

Weekly Downloads

409

Version

1.0.1

License

MIT

Unpacked Size

10.4 kB

Total Files

5

Last publish

Collaborators

  • wecom-bot