public async Task <RES_ENCRYTO_DATA> TestEcho3(REQ_ENCRYTO_DATA requestPacket) { try { var jsonObject = DecryptRequestData <REQ_DEV_ECHO>(requestPacket.Data); var result = await APILogicLib.Request.TestEcho3.Process(jsonObject); return(EncryotResponseData <RES_DEV_ECHO>(result)); } catch (Exception ex) { Logger.Exception(ex.ToString()); var result = new RES_ENCRYTO_DATA(); result.Result = (short)ERROR_ID.REQUEST_PACKET_DECRYPT; return(result); } }
static async Task <RESULT_T> RequestHttpAESEncry <RESULT_T>(string api, string loginSeq, string userID, string jsonText) where RESULT_T : IRES_DATA, new() { var dynamicKey = "f&dsf"; var resultData = new RESULT_T(); var encryData = AESEncrypt.Encrypt(loginSeq, jsonText); var sendData = new REQ_ENCRYTO_DATA { ID = userID, Data = encryData }; var requestJson = Jil.JSON.Serialize <REQ_ENCRYTO_DATA>(sendData); var content = new ByteArrayContent(Encoding.UTF8.GetBytes(requestJson)); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var network = new System.Net.Http.HttpClient(); var response = await network.PostAsync(api, content).ConfigureAwait(false); if (response.IsSuccessStatusCode == false) { resultData.SetResult(ERROR_ID.CLIENT_HTTP_NETWOR_CONNECT); return(resultData); } var responeString = await response.Content.ReadAsStringAsync(); var responseJson = Jil.JSON.Deserialize <RES_ENCRYTO_DATA>(responeString); if (responseJson.Result != (short)ERROR_ID.NONE) { resultData.SetResult((ERROR_ID)responseJson.Result); return(resultData); } var decryptData = AESEncrypt.Decrypt(dynamicKey, responseJson.Data); resultData = Jil.JSON.Deserialize <RESULT_T>(decryptData); return(resultData); }