protected override T parseResponse <T>(string resp, BaseRequest <T> request) { try { resp = AESUtil.DecryptFromBase64String(resp, this.randomKey); return(base.parseResponse <T>(resp, request)); } catch (Exception e) { throw new Exception("AES解密失败", e); } }
public void TestAES() { String content = "我爱你"; String password = "******"; String ret2 = AESUtil.EncryptToBase64String(content, password); String content3 = AESUtil.DecryptFromBase64String(ret2, password); Assert.IsTrue(content == (content3)); }
protected virtual void checkHandshakeResponse(string resp, string randomKey) { StringResponse result = JsonUtil.ParseObject <StringResponse>(resp); if (!result.IsSuccess()) { throw new SystemException(result.msg); } string data = result.data; string desStr = RSAUtil.DecryptByPublicKey(data, publicKey); string content = AESUtil.DecryptFromBase64String(desStr, randomKey); // 一致 bool same = MD5Util.Encrypt(randomKey) == content; if (!same) { throw new SystemException("传输错误"); } }