예제 #1
0
        protected internal virtual GSTNResult <FileInfo> SignFile(UnsignedDataInfo unsignedDataInfo, string sign, string st, string sid, string ret_prd)
        {
            this.url2 = this.url2.Split('?')[0];
            SignedDataInfo model = new SignedDataInfo
            {
                action = "RETFILE",
                sign   = sign,
                st     = st,
                sid    = sid,
                data   = unsignedDataInfo.data
            };

            var info   = this.Post <SignedDataInfo, ResponseDataInfo>(model);
            var output = this.Decrypt <FileInfo>(info.Data);
            var model2 = this.BuildResult <FileInfo>(info, output);

            System.Console.WriteLine("Obtained Result:" + info.Data.ack_num + System.Environment.NewLine);
            return(model2);
        }
예제 #2
0
        protected internal UnsignedDataInfo Encrypt <T>(T input)
        {
            UnsignedDataInfo info = new UnsignedDataInfo();

            if (input != null)
            {
                string finalJson = JsonConvert.SerializeObject(input, Newtonsoft.Json.Formatting.Indented,
                                                               new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore
                });
                byte[] encodeJson    = UTF8Encoding.UTF8.GetBytes(finalJson);
                string base64Payload = Convert.ToBase64String(encodeJson);
                byte[] jsonData      = UTF8Encoding.UTF8.GetBytes(base64Payload);
                info.data = EncryptionUtils.AesEncrypt(jsonData, provider.DecryptedKey);
                info.hmac = EncryptionUtils.GenerateHMAC(jsonData, provider.DecryptedKey);
            }
            return(info);
        }