Crate wecom_crypto

Source
Expand description

§wecom-crypto

wecom-crypto提供了企业微信API数据的加解密功能。其实现完全遵循官方文档中的规定。

§使用方法

use wecom_crypto::{Agent, Source};

let token = "a";
let key = "cGCVnNJRgRu6wDgo7gxG2diBovGnRQq1Tqy4Rm4V4qF";
let agent = Agent::new(token, key);
let source = Source {
    text: "hello world!".to_string(),
    receive_id: "wandering-ai".to_string(),
};
let enc = agent.encrypt(&source);
let dec = agent.decrypt(enc.as_str()).unwrap();
assert_eq!(source, dec);

Structs§

Agent
加解密功能代理。是加解密方法的数据结构载体。
Source
加解密数据结构体。

Enums§

CryptoError
加解密过程中可能出现的错误

Functions§

generate_sha1_signature
生成数据签名,用于校验请求数据是否被篡改。输入需要包含Token。