Exemplo n.º 1
0
        private static TRes DecryptTo <TRes>(this WechatMAppEncryptBody encryptBody, string sessionKey)
        {
            try
            {
                var encryptDataBytes = Convert.FromBase64String(encryptBody.encrypt_data);
                var sesssionKeyBytes = Convert.FromBase64String(sessionKey);
                var ivBytes          = Convert.FromBase64String(encryptBody.iv);

                var result = Encoding.UTF8.GetString(AesRijndael.Decrypt(sesssionKeyBytes, encryptDataBytes, ivBytes, 128,
                                                                         128, CipherMode.CBC));

                return(JsonConvert.DeserializeObject <TRes>(result));
            }
            catch
            {
            }

            return(default);
Exemplo n.º 2
0
 public static WechatUserPhoneInfo ToUserPhone(this WechatMAppEncryptBody encryptBody, string sessionKey)
 {
     return(encryptBody.DecryptTo <WechatUserPhoneInfo>(sessionKey));
 }