コード例 #1
0
        protected internal T Decrypt <T>(ResponseDataInfo output)
        {
            T model = default(T);

            if (output.status_cd != "0")
            {
                byte[] decryptREK = EncryptionUtils.AesDecrypt(output.rek, provider.DecryptedKey);
                byte[] jsonData   = EncryptionUtils.AesDecrypt(output.data, decryptREK);
                string testHmac   = EncryptionUtils.GenerateHMAC(jsonData, decryptREK);
                System.Console.WriteLine("HMAC Match:" + (output.hmac == testHmac));
                string base64Payload = UTF8Encoding.UTF8.GetString(jsonData);
                byte[] decodeJson    = Convert.FromBase64String(base64Payload);
                string finalJson     = Encoding.UTF8.GetString(decodeJson);
                model    = Newtonsoft.Json.JsonConvert.DeserializeObject <T>(finalJson);
                LastJson = finalJson;
            }
            return(model);
        }
コード例 #2
0
        public GSTNResult <TokenResponseModel> RefreshToken()
        {
            RefreshTokenModel model = new RefreshTokenModel
            {
                action   = "REFRESHTOKEN",
                username = userid
            };

            model.app_key    = EncryptionUtils.AesEncrypt(GSTNConstants.GetAppKeyBytes(), this.DecryptedKey);
            model.auth_token = this.AuthToken;
            var output = this.Post <RefreshTokenModel, TokenResponseModel>(model);

            token             = output.Data;
            this.AuthToken    = token.auth_token;
            this.DecryptedKey = EncryptionUtils.AesDecrypt(token.sek, GSTNConstants.GetAppKeyBytes());
            var Decipher = System.Text.Encoding.UTF8.GetString(DecryptedKey);

            return(output);
        }
コード例 #3
0
        public GSTNResult <TokenResponseModel> RequestToken(string otp)
        {
            TokenRequestModel model = new TokenRequestModel {
                action   = "AUTHTOKEN",
                username = userid
            };

            model.app_key = EncryptionUtils.RsaEncrypt(GSTNConstants.GetAppKeyBytes());
            byte[] dataToEncrypt = UTF8Encoding.UTF8.GetBytes(otp);
            model.otp = EncryptionUtils.AesEncrypt(dataToEncrypt, GSTNConstants.GetAppKeyBytes());
            var output = this.Post <TokenRequestModel, TokenResponseModel>(model);

            this.userid       = userid;
            token             = output.Data;
            this.AuthToken    = token.auth_token;
            this.DecryptedKey = EncryptionUtils.AesDecrypt(token.sek, GSTNConstants.GetAppKeyBytes());
            var Decipher = System.Text.Encoding.UTF8.GetString(DecryptedKey);

            return(output);
        }