pub struct WechatCrypto { /* private fields */ }Implementations§
Source§impl WechatCrypto
impl WechatCrypto
pub fn new(encoding_aes_key: &str) -> WechatCrypto
pub fn token(self, token: &str) -> WechatCrypto
pub fn receive_id(self, receive_id: &str) -> WechatCrypto
Sourcepub fn get_signature(
&self,
timestamp: i64,
nonce: &str,
encrypted: &str,
) -> String
pub fn get_signature( &self, timestamp: i64, nonce: &str, encrypted: &str, ) -> String
§获取签名
timestamp 时间戳 nonce 随机字符串 encrypted 加密数据
Sourcepub fn get_sha1_sign(encrypt_str: &str) -> String
pub fn get_sha1_sign(encrypt_str: &str) -> String
SHA1签名
Sourcepub fn create_hmac_sha256_sign(
key: &str,
message: &str,
) -> LabradorResult<String>
pub fn create_hmac_sha256_sign( key: &str, message: &str, ) -> LabradorResult<String>
hmac_sha256
Sourcepub fn decrypt_data(
session_key: &str,
encrypted_data: &str,
iv: &str,
) -> LabradorResult<String>
pub fn decrypt_data( session_key: &str, encrypted_data: &str, iv: &str, ) -> LabradorResult<String>
§数据解密
session_key key iv 偏移量 encrypted_data 加密数据
Sourcepub fn check_signature(
&self,
signature: &str,
timestamp: i64,
nonce: &str,
echo_str: &str,
) -> LabradorResult<bool>
pub fn check_signature( &self, signature: &str, timestamp: i64, nonce: &str, echo_str: &str, ) -> LabradorResult<bool>
§检查签名
timestamp 时间戳 nonce 随机字符串 echo_str 加密数据
Sourcepub fn encrypt_message(
&self,
msg: &str,
timestamp: i64,
nonce: &str,
) -> LabradorResult<String>
pub fn encrypt_message( &self, msg: &str, timestamp: i64, nonce: &str, ) -> LabradorResult<String>
§加密消息
timestamp 时间戳 nonce 随机字符串 msg 加密数据
Sourcepub fn decrypt_message(
&self,
xml: &str,
signature: &str,
timestamp: i64,
nonce: &str,
) -> LabradorResult<String>
pub fn decrypt_message( &self, xml: &str, signature: &str, timestamp: i64, nonce: &str, ) -> LabradorResult<String>
§解密消息
xml 解密内容 nonce 随机字符串 timestamp 时间戳 signature 签名
Sourcepub fn decrypt_content(
&self,
encrypted_content: &str,
signature: &str,
timestamp: i64,
nonce: &str,
) -> LabradorResult<String>
pub fn decrypt_content( &self, encrypted_content: &str, signature: &str, timestamp: i64, nonce: &str, ) -> LabradorResult<String>
§检验消息的真实性,并且获取解密后的明文.
- 利用收到的密文生成安全签名,进行签名验证
- 若验证通过,则提取xml中的加密消息
- 对消息进行解密
Sourcepub fn decrypt_xml(
&self,
encrypted_xml: &str,
signature: &str,
timestamp: i64,
nonce: &str,
) -> LabradorResult<String>
pub fn decrypt_xml( &self, encrypted_xml: &str, signature: &str, timestamp: i64, nonce: &str, ) -> LabradorResult<String>
§检验消息的真实性,并且获取解密后的明文.
- 利用收到的密文生成安全签名,进行签名验证
- 若验证通过,则提取xml中的加密消息
- 对消息进行解密
Sourcepub fn decrypt_data_refund(
app_key: &str,
ciphertext: &str,
) -> LabradorResult<String>
pub fn decrypt_data_refund( app_key: &str, ciphertext: &str, ) -> LabradorResult<String>
§解密退款消息
app_key 应用key ciphertext 加密数据
Trait Implementations§
Source§impl Debug for WechatCrypto
impl Debug for WechatCrypto
Source§impl PartialEq for WechatCrypto
impl PartialEq for WechatCrypto
impl Eq for WechatCrypto
impl StructuralPartialEq for WechatCrypto
Auto Trait Implementations§
impl Freeze for WechatCrypto
impl RefUnwindSafe for WechatCrypto
impl Send for WechatCrypto
impl Sync for WechatCrypto
impl Unpin for WechatCrypto
impl UnwindSafe for WechatCrypto
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.