1.0.1 • Published 2 years ago

@wecom/crypto v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@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 });