Example #1
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);
        }
Example #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);
        }
Example #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);
        }