Exemplo n.º 1
0
        protected internal UnsignedDataInfo Encrypt <T>(T input)
        {
            string           finalJson = this.Serialize(input);
            UnsignedDataInfo info      = this.EncryptPayload(finalJson);

            return(info);
        }
Exemplo n.º 2
0
        protected internal UnsignedDataInfo EncryptBase64(string base64Payload)
        {
            UnsignedDataInfo info = new UnsignedDataInfo();

            byte[] jsonData = UTF8Encoding.UTF8.GetBytes(base64Payload);
            info.data = EncryptionUtils.AesEncrypt(jsonData, provider.DecryptedKey);
            info.hmac = EncryptionUtils.GenerateHMAC(jsonData, provider.DecryptedKey);
            return(info);
        }
Exemplo n.º 3
0
        protected internal UnsignedDataInfo EncryptPayload(string finalJson)
        {
            UnsignedDataInfo info = new UnsignedDataInfo();

            dicParams.Add("RequestPayload", finalJson);
            byte[] encodeJson    = UTF8Encoding.UTF8.GetBytes(finalJson);
            string base64Payload = Convert.ToBase64String(encodeJson);

            return(this.EncryptBase64(base64Payload));
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }