Ejemplo n.º 1
0
        protected internal UnsignedDataInfo Encrypt <T>(T input)
        {
            UnsignedDataInfo info = new UnsignedDataInfo();

            if (input != null)
            {
                string finalJson  = JsonConvert.SerializeObject(input);
                byte[] encodeJson = Encoding.UTF8.GetBytes(finalJson);
                string json       = Convert.ToBase64String(encodeJson);
                byte[] jsonData   = Encoding.UTF8.GetBytes(json);
                info.data = EncryptionUtils.AesEncrypt(jsonData, provider.DecryptedKey);
                info.hMAC = EncryptionUtils.GenerateHMAC(json, provider.DecryptedKey);
            }
            return(info);
        }
Ejemplo n.º 2
0
        protected internal virtual GSTNResult <FileInfo> SignFile(UnsignedDataInfo data, string sign, string st, string sid)
        {
            SignedDataInfo model = new SignedDataInfo
            {
                action = "RETFILE",
                sign   = sign,
                st     = st,
                sid    = sid
            };

            model.data = data.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:" + model2.Data.ack_num + System.Environment.NewLine);
            return(model2);
        }
Ejemplo n.º 3
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);
        }