Example #1
0
        private void LoadLicenseStatus()
        {
            GlobalSettings gs = new GlobalSettings();

            gs.LoadSettings();
            tbLicenseKey.Text = gs.GetSettingValueOrDefault("LicenseKey", "");

            if (tbLicenseKey.Text.Trim() == "")
            {
                lblLicenseInfo.Text = "";
                return;
            }

            if (CryptLib.isKeyValid(tbLicenseKey.Text))
            {
                try
                {
                    string key = gs.GetSettingValueOrDefault("LicenseKey", "");
                    lblLicenseInfo.Text  = "Aktualne dane licencyjne.\n";
                    lblLicenseInfo.Text += "\nWażna od: " + CryptLib.getDateFrom(key);
                    lblLicenseInfo.Text += "\nWażna do: " + CryptLib.getDateTo(key);
                    lblLicenseInfo.Text += "\nLiczba użytkowników: " + CryptLib.getNumOfUsers(key);
                    lblLicenseInfo.Text += "\nLiczba firm: " + CryptLib.getNumOfCompanies(key);
                }
                catch
                {
                    GlobalVariables.ShowMessage("Błąd w numerze licencji.", "Licencja - błąd", 3);
                }
            }
            else
            {
                lblLicenseInfo.Text = "Błędna licencja";
                GlobalVariables.ShowMessage("Błąd w numerze licencji.", "Licencja - błąd", 3);
            }
        }
Example #2
0
        private string[] Transform(string file, string[] data)
        {
            String iv  = "";
            string key = "";

            var application = new Microsoft.Office.Interop.Word.Application();

            Microsoft.Office.Interop.Word.Document document = application.Documents.Open(file);

            int    count = document.Words.Count;
            string s2    = "";

            for (int i = 1; i <= count; i++)
            {
                string text = document.Words[i].Text;
                s2 = s2 + text;
            }
            String cypherText = "";

            if (data[0] == null)
            {
                iv = CryptLib.GenerateRandomIV(16);
                Random random = new Random();

                key     = getHashSha256(random.Next(6, 8).ToString(), 31);
                data[0] = iv;
                data[1] = key;
            }
            cypherText = Encrypt(s2, data[1], data[0]);

            document.Content.Text = cypherText;
            document.Close(true);
            application.Quit(true);
            return(data);
        }
Example #3
0
 public ActionResult ResetPassword(string param = null, string IV = null)
 {
     if (param != null)
     {
         ResetPasswordViewModel result = new ResetPasswordViewModel();
         CryptLib cryptLib             = new CryptLib();
         string   key = CryptLib.getHashSha256("hrkey", 31);
         string   emailtimeout = ""; string email = ""; string timeout = "";
         try
         {
             emailtimeout = cryptLib.decrypt(param, key, IV);
             string[] paramlist = emailtimeout.Split(',');
             email   = paramlist[0];
             timeout = paramlist[1];
             DateTime expiredate = Convert.ToDateTime(timeout);
             if (expiredate > DateTime.Now)
             {
                 result.Email = email;
             }
             else
             {
                 return(View("Error"));
             }
         }
         catch (Exception ex)
         {
             return(View("Error"));
         }
         return(View(result));
     }
     else
     {
         return(View("Error"));
     }
 }
Example #4
0
        public IHttpActionResult getEncrypt(dynamic data)
        {
            dynamic objenc = new ExpandoObject();

            try
            {
                string json = JsonConvert.SerializeObject(data);

                string iv  = CryptLib.GenerateRandomIV(16);
                string key = CryptLib.getHashSha256("GSWS TEST", 32);

                string encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(json, key, iv);

                objenc.Status      = 100;
                objenc.encrypttext = encrypttext;
                objenc.key         = iv;
                objenc.Reason      = "";
                return(Ok(objenc));
            }
            catch (Exception ex)
            {
                objenc.Status = 102;
                objenc.Reason = ex.Message.ToString();
                return(Ok(objenc));
            }
        }
Example #5
0
        public void Update(UserModel model)
        {
            var data = this._repoUser.Find(model.id);

            if (model.username != data.username)
            {
                if (this._repoUser.Query().Filter(x => x.username == model.username).Get().Any())
                {
                    throw new Exception(model.username + " is already exists.");
                }
                data.username = model.username;
            }

            if (model.UserStatus.value == (int)UserStatus.ResetPassword)
            {
                CryptLib _crypt          = new CryptLib();
                string   defaultPassword = GetSettingValue("DEFAULT_PASSWORD");
                string   hashShaKey      = GetSettingValue("HRIS_HASHSHA_KEY");
                string   key             = CryptLib.getHashSha256(hashShaKey, 31); //32 bytes = 256 bits
                string   iv        = CryptLib.GenerateRandomIV(16);
                string   encrypted = _crypt.encrypt(defaultPassword, key, iv);
                data.password = encrypted;
                data.hashKey  = key;
                data.vector   = iv;
            }

            data.email  = model.email;
            data.status = model.UserStatus.value;
            this._repoUser.Update(data);
            this._unitOfWork.Save();
        }
Example #6
0
        public void UpdateProfile(AccountProfileModel model)
        {
            Guid userId = this.GetCurrentUserId();
            var  data   = this._repoUser.Find(userId);

            if (!string.IsNullOrEmpty(model.password))
            {
                if (string.IsNullOrEmpty(model.newPassword))
                {
                    throw new Exception("Please provide new password.");
                }

                CryptLib _crypt = new CryptLib();

                string decryptedPassword = _crypt.decrypt(data.password, data.hashKey, data.vector);
                if (decryptedPassword != model.password)
                {
                    throw new Exception("Invalid Password.");
                }

                string hashShaKey = GetSettingValue("HRIS_HASHSHA_KEY");
                string key        = CryptLib.getHashSha256(hashShaKey, 31); //32 bytes = 256 bits
                string iv         = CryptLib.GenerateRandomIV(16);
                string encrypted  = _crypt.encrypt(model.newPassword, key, iv);
                data.password = encrypted;
                data.hashKey  = key;
                data.vector   = iv;
            }

            data.email       = model.email;
            data.updatedBy   = userId;
            data.updatedDate = DateTime.Now;
            this._repoUser.Update(data);
            this._unitOfWork.Save();
        }
Example #7
0
        public void Create(UserModel model, out Guid userId)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                Guid companyId = this.GetCurrentCompanyId();
                if (this._repoUser.Query().Filter(x => x.username == model.username).Get().Any())
                {
                    throw new Exception(model.username + " is already exists.");
                }

                var currentUser = this.GetCurrentUserId();

                CryptLib _crypt          = new CryptLib();
                string   defaultPassword = GetSettingValue("DEFAULT_PASSWORD");
                string   key             = CryptLib.getHashSha256(GetSettingValue("HRIS_HASHSHA_KEY"), 31); //32 bytes = 256 bits
                string   iv        = CryptLib.GenerateRandomIV(16);
                string   encrypted = _crypt.encrypt(defaultPassword, key, iv);

                var ins = this._repoUser.Insert(new sys_User()
                {
                    companyId = this.GetCurrentCompanyId(),
                    username  = model.username,
                    password  = encrypted,
                    email     = model.email,
                    hashKey   = key,
                    vector    = iv,
                    status    = (int)UserStatus.Active,
                    updatedBy = currentUser,
                });
                this._unitOfWork.Save();
                ts.Complete();
                userId = ins.id;
            }
        }
Example #8
0
    public static string Decrypt(string data, string key, string iv)
    {
        CryptLib _crypt = new CryptLib();

        //16 bytes = 128 bits
        key = CryptLib.getHashSha256(key, 32); //32 bytes = 256 bits
        return(_crypt.decrypt(data, key, iv));
    }
Example #9
0
        public ActionResult Index()
        {
            CryptLib objCrypt        = new CryptLib();
            string   encryptedString = objCrypt.encrypt("test:123", key, iv);

            ViewBag.Title = "Home Page";
            return(View());
        }
Example #10
0
        //-> encrypt string
        public static string EncryptString(string pwd)
        {
            CryptLib _crypt    = new CryptLib();
            string   plainText = pwd;
            string   iv        = "Xsoft";                                    // CryptLib.GenerateRandomIV(16); //16 bytes = 128 bits
            string   key       = CryptLib.getHashSha256("@XSoft201701", 31); //32 bytes = 256 bits

            return(_crypt.encrypt(plainText, key, iv));
        }
        public async Task <ActionResult <LoginResponse> > Login(Login data)
        {
            string cfg_key = _config.GetValue <string>("api_key:key");
            string json    = string.Empty;

            json = Newtonsoft.Json.JsonConvert.SerializeObject(data);
            _log.LogInformation("Request login <==" + json);
            fData        _res     = new fData();
            ActionResult response = Unauthorized();
            CryptLib     scry     = new CryptLib();

            try
            {
                if (key == cfg_key)
                {
                    string desc   = scry.decrypt(data.password);
                    var    result = await _db.getlogin(data.username, data.password);

                    if (result != null)
                    {
                        result.token = GenerateToken(data);
                        _res         = new fData();
                        _res.data    = result;
                        _res.rc      = "00";
                        _res.desc    = "Login berhasil dilakukan";
                        response     = Ok(_res);
                    }
                    else
                    {
                        _res      = new fData();
                        _res.data = result;
                        _res.rc   = "05";
                        _res.desc = "Login gagal dilakukan";
                        response  = StatusCode(400, _res);
                    }
                }
                else
                {
                    _res      = new fData();
                    _res.rc   = "05";
                    _res.desc = "Apikey tidak sesuai";
                    response  = StatusCode(401, _res);
                }
            }
            catch (MyException ex)
            {
                _log.LogError(ex.Message.ToString());
                _res      = new fData();
                _res.rc   = "05";
                _res.desc = "Internal system Error";
                response  = StatusCode(501, _res);
            }
            string json2 = Newtonsoft.Json.JsonConvert.SerializeObject(response);

            _log.LogInformation("Response Login <== " + json2.ToString());
            return(response);
        }
Example #12
0
    public static string Encrypt(string data, string key)
    {
        CryptLib _crypt = new CryptLib();
        String   iv     = CryptLib.GenerateRandomIV(16); //16 bytes = 128 bits

        key = CryptLib.getHashSha256(key, 31);           //32 bytes = 256 bits
        String cypherText = _crypt.encrypt(data, key, iv);

        return(cypherText);
    }
Example #13
0
 /// <summary>
 /// Get the connection for MySQL Server
 /// </summary>
 /// <returns></returns>
 /// <exception cref="Exception"></exception>
 public string GetConnectionStringForMySql()
 {
     try
     {
         CryptLib aDTool = new CryptLib();
         return(String.IsNullOrEmpty(Port)
             ? $"database={this.Database}; server={this.ServerName}; SslMode={this.SslMode}; user id={this.User}; pwd={aDTool.Decrypt(this.Password)}"
             : $"database={this.Database}; server={this.ServerName}; Port={this.Port}; SslMode={this.SslMode}; user id={this.User}; pwd={aDTool.Decrypt(this.Password)}");
     }
     catch (Exception ex) { throw ex; }
 }
Example #14
0
 /// <summary>
 /// Get the connection For SQL Server
 /// </summary>
 /// <returns></returns>
 /// <exception cref="Exception"></exception>
 public string GetConnectionStringForSql()
 {
     try
     {
         CryptLib aDTool = new CryptLib();
         return(Convert.ToBoolean(this.IntegratedSecurity ?? "False") ?
                $"Data Source={this.ServerName};Initial Catalog={this.Catalog};Integrated Security=True;Pooling=False;MultipleActiveResultSets=True;" :
                $"Data Source={this.ServerName};Initial Catalog={this.Catalog};User Id={this.User};Password={aDTool.Decrypt(this.Password)};Connection Timeout={this.ConnectionTimeOut};Pooling=False;MultipleActiveResultSets=True;");
     }
     catch (Exception ex) { throw ex; }
 }
		public static void Main (String []args)
		{
			CryptLib _crypt = new CryptLib ();
			string plainText = "This is the text to be encrypted";
			String iv = CryptLib.GenerateRandomIV (16); //16 bytes = 128 bits
			string key = CryptLib.getHashSha256("my secret key", 31); //32 bytes = 256 bits
			String cypherText = _crypt.encrypt (plainText, key, iv);
			Console.WriteLine ("iv="+iv);
			Console.WriteLine ("key=" + key);
			Console.WriteLine("Cypher text=" + cypherText);
			Console.WriteLine ("Plain text =" + _crypt.decrypt (cypherText, key, iv));
		}
    private static void Main(string[] args)
    {
        CryptLib crypt = new CryptLib("password", "iv");

            string encryptedText = crypt.Encrypt("this is a secret message");
            Console.WriteLine(encryptedText);

            string decryptedText = crypt.Decrypt(encryptedText);
            Console.WriteLine(decryptedText);

            Console.ReadLine();
    }
Example #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string iv      = "4QesEr03HwE5H1C+ICw7SA==";                     // origional iv 128 bits
            string key     = "ovA6siPkyM5Lb9oNcnxLz676K6JK6FrJKk4efEUWBzg="; // origional key 256 bits
            string message = "Meet me at the secret location at 8pm";

            CryptLib cryptLib      = new CryptLib();
            string   encryptedText = cryptLib.encrypt(message, key, iv);

            string originalMessage = cryptLib.decrypt(encryptedText, key, iv);

            Debug.WriteLine(originalMessage);
        }
Example #18
0
 public static bool PermiteAcesso(string token, string chave)
 {
     CryptLib critografia = new CryptLib();
     string openedToken = critografia.Decript(token, chave);
     if (openedToken == "EcoSistemasInovacaoEmGestaoDeSaude")
     {
         return true;
     }
     else
     {
         return false;
     }
 }
    public static void Main(String [] args)
    {
        CryptLib _crypt     = new CryptLib();
        string   plainText  = "This is the text to be encrypted";
        String   iv         = CryptLib.GenerateRandomIV(16);               //16 bytes = 128 bits
        string   key        = CryptLib.getHashSha256("my secret key", 31); //32 bytes = 256 bits
        String   cypherText = _crypt.encrypt(plainText, key, iv);

        Console.WriteLine("iv=" + iv);
        Console.WriteLine("key=" + key);
        Console.WriteLine("Cypher text=" + cypherText);
        Console.WriteLine("Plain text =" + _crypt.decrypt(cypherText, key, iv));
    }
Example #20
0
        public void ValidateLogin(string companyCode, string username, string password, out Guid sessionId)
        {
            using (TransactionScope ts = new TransactionScope())
            {
                Guid companyId = this._repoCompany.Query().Filter(x => x.code == companyCode).Get().Select(x => x.id).FirstOrDefault();

                var checkUser = this._repoUser.Query().Filter(x => x.username == username && x.companyId == companyId).Get();

                if (!checkUser.Any())
                {
                    throw new Exception("Invalid Username");
                }

                var user = checkUser.Single();

                var status = (UserStatus)user.status;

                switch (status)
                {
                case UserStatus.Disabled:
                    throw new Exception("User has been disabled");

                case UserStatus.Locked:
                    throw new Exception("User has been Locked");

                default:
                    break;
                }

                CryptLib _crypt     = new CryptLib();
                string   hashShaKey = GetSettingValue(companyId, "HRIS_HASHSHA_KEY");
                string   key        = CryptLib.getHashSha256(hashShaKey, 31); //32 bytes = 256 bits
                                                                              //string encrypted = _crypt.encrypt(password, key, iv);
                string decrypt = _crypt.decrypt(user.password, user.hashKey, user.vector);

                if (decrypt != password)
                {
                    throw new Exception("Invalid Password");
                }

                sessionId = this.CreateUserSession(companyId, user.id);

                if (status == UserStatus.ResetPassword)
                {
                    this.UpdateStatus(user.id, UserStatus.Active);
                }

                ts.Complete();
            }
        }
Example #21
0
        public dynamic initiateSpandanaTransaction(transactionModel obj)
        {
            dynamic objdata = new ExpandoObject();

            try
            {
                obj.TYPE       = "1";
                obj.IP_ADDRESS = HttpContext.Current.Request.UserHostAddress;
                obj.SYS_NAME   = System.Environment.MachineName;
                obj.TXN_ID     = obj.SECRETRAINT_CODE + DateTime.Now.ToString("yymmddHHmm") + new Random().Next(1000, 9999);
                DataTable dt = transactionInsertion(obj);

                if (dt != null && dt.Rows.Count > 0)
                {
                    string encrypttext = "";
                    string iv          = "";

                    iv = CryptLib.GenerateRandomIV(16);
                    string key  = CryptLib.getHashSha256("GSWS TEST", 32);
                    string obj2 = GetInputJsonFormat(obj);
                    encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(obj2, key, iv);

                    objdata.status = 200;
                    if (obj.URL_ID == "340200101")
                    {
                        objdata.URL = "https://www.spandana.ap.gov.in/gsws/servicegrievance_registration?accessToken=" + Token() + "&Volunteerid=2255667788&AadhaarNo=" + obj.UID + "&vvstype=VVS2&DistId=" + obj.Sdistcode + "&MandalId=" + obj.Smcode + "&GpId=" + obj.Svtcode + "&GpFlag=" + obj.SRuflag + "&encryptId=" + encrypttext + "&KEY=" + key + "&IV=" + iv;
                    }
                    else
                    {
                        objdata.URL = "https://www.spandana.ap.gov.in/gsws/servicerequest_registration?HodId=" + obj.SERVICE_CODE + "&accessToken= " + Token() + "&Volunteerid=2255667788&AadhaarNo=" + obj.UID + "&vvstype=VVS2&DistId=" + obj.Sdistcode + "&MandalId=" + obj.Smcode + "&GpId=" + obj.Svtcode + "&GpFlag=" + obj.SRuflag + "&encryptId=" + encrypttext + "&KEY=" + key + "&IV=" + iv;
                    }


                    objdata.Reason = "Record Inserted Successfully !!!";
                }
                else
                {
                    objdata.status = 400;
                    objdata.Reason = "Failed to Insert Record, Please Try Again !!! ";
                }
            }
            catch (Exception ex)
            {
                objdata.status = 500;
                objdata.Reason = "Something Went Wrong.Please Try Again";                //ex.Message.ToString();
            }

            return(objdata);
        }
Example #22
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Console.WriteLine("Hello World again 12!");

            CryptLib _crypt     = new CryptLib();
            string   plainText  = "This is the text to be encrypted.";
            String   iv         = "4NAfcTL5nWERGSLl";                          //CryptLib.GenerateRandomIV(16); //16 bytes = 128 bits
            string   key        = CryptLib.getHashSha256("my secret key", 32); //32 bytes = 256 bits
            String   cypherText = _crypt.encrypt(plainText, key, iv);

            Console.WriteLine("isv=" + iv);
            Console.WriteLine("key=" + key);
            Console.WriteLine("Cypher text=" + cypherText);
            Console.WriteLine("Plain text =" + _crypt.decrypt(cypherText, key, iv));
        }
Example #23
0
 public ActionResult ForgotPassword(ForgotPasswordViewModel model)
 {
     if (ModelState.IsValid)
     {
         HumanResourceContext context = new HumanResourceContext();
         Account result = context.AccountSet.Where(e => e.Email == model.Email).FirstOrDefault();
         if (result == null)
         {
             return(View("ForgotPasswordConfirmation"));
         }
         else
         {
             string   To = result.Email, UserID, Password, SMTPPort, Host;
             CryptLib cl           = new CryptLib();
             String   key          = CryptLib.getHashSha256("hrkey", 31); //32 bytes = 256 bit
             String   em           = CryptLib.GenerateRandomIV(16);       //16 bytes = 128 bit
             string   timeout      = DateTime.Now.AddMinutes(30).ToString();
             string   emailtimeout = model.Email + "," + timeout;
             try
             {
                 emailtimeout = cl.encrypt(emailtimeout, key, em);
             }
             catch
             {
                 emailtimeout = "";
             }
             var lnkHref = "<a href='" + Url.Action("ResetPassword", "UserLogin", new { param = emailtimeout, IV = em }, "http") + "'>Reset Password</a>";
             //var lnkHref = "<a href='"+ Url.Action("ResetPassword", "UserLogin", new { param = emailtimeout, IV = em }) + "'>Reset Password</a>";
             //HTML Template for Send email
             string subject = "Your changed password";
             string body    = "<html><body><b>You can reset your password here. </b><br/>" + lnkHref + "</body></html>";
             //Get and set the AppSettings using configuration manager.
             AppSettings(out UserID, out Password, out SMTPPort, out Host);
             //Call send email methods.
             SendEmail(UserID, subject, body, To, UserID, Password, SMTPPort, Host);
         }
     }
     ViewBag.sendmessage = "Reset password link has been sent to your email.";
     return(View());
 }
Example #24
0
        static void Main(string[] args)
        {
            /*
             * Testing the function logs
             *
             * LogManager<LogJsonFile> logManager = new LogManager<LogJsonFile>();
             * logManager.LoadLog(Path.Combine(FileManager.GetApplicationPath(), "logFileTmpNotExists"));
             * var listLog = logManager.GetLog();
             * logManager.AddLog(new LogJsonFile("jairo","read","warning read",LogType.Warning, new LogException("...","...","...","..."), null));
             * logManager.SaveLog();
             *
             */


            var connDec = new CryptLib().Decrypt("B9jejyAzaRNYBUUQMcVYK1JfaTafPiMiGWFJaXo1t2xdRG6futk7bHrxd8uCoY/Sr/gsoJ9DysqB6SJnAjExZmy7CpyiuSBkbJ6HM45WYZWiYR90WBkG56HUAUzyluy7059o80xoEtl2oc8SXQpjSQ==");
            var connEnc = new CryptLib().Encrypt("Data Source=localhost; Initial Catalog=ProjectControlTime; Integrated Security=false; user id=sa; password=1234;");

            EnvironmentManager <EnvironmentTest> envManager = new EnvironmentManager <EnvironmentTest>();

            envManager.LoadEnvironment(Path.Combine(FileManager.GetApplicationPath(), "env.cfg"));
            EnvironmentTest envActive = envManager.ActivEnvironment();
            int             tmp       = 0;
        }
Example #25
0
        public void UpdateStatus(Guid userId, UserStatus status)
        {
            var data = this._repoUser.Find(userId);

            data.status = (int)status;

            if (status == UserStatus.ResetPassword)
            {
                CryptLib _crypt          = new CryptLib();
                string   defaultPassword = GetSettingValue("DEFAULT_PASSWORD");
                string   hashShaKey      = GetSettingValue("HRIS_HASHSHA_KEY");
                string   key             = CryptLib.getHashSha256(hashShaKey, 31); //32 bytes = 256 bits
                string   iv = CryptLib.GenerateRandomIV(16);

                string encrypted = _crypt.encrypt(defaultPassword, key, iv);
                data.password = encrypted;
                data.hashKey  = key;
                data.vector   = iv;
            }

            this._repoUser.Update(data);
            this._unitOfWork.Save();
        }
Example #26
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     lbl_encrypted.Text = CryptLib.Encrypt(txt_encr.Text);
 }
Example #27
0
        public dynamic initiateTransaction(transactionModel obj)
        {
            dynamic objdata = new ExpandoObject();

            try
            {
                obj.TYPE       = "1";
                obj.IP_ADDRESS = HttpContext.Current.Request.UserHostAddress;
                obj.SYS_NAME   = System.Environment.MachineName;
                obj.TXN_ID     = obj.SECRETRAINT_CODE + DateTime.Now.ToString("yyMMddHHmm") + new Random().Next(1000, 9999);
                DataTable dt = transactionInsertion(obj);

                if (dt != null && dt.Rows.Count > 0)
                {
                    string encrypttext = "";
                    string iv          = "";
                    if (obj.TYPE_OF_SERVICE == "1")
                    {
                        iv = CryptLib.GenerateRandomIV(16);
                        string key  = CryptLib.getHashSha256("GSWS TEST", 32);
                        string obj2 = GetInputJsonFormat(obj);
                        encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(obj2, key, iv);
                    }
                    else if (obj.URL_ID == "110401301" || obj.URL_ID == "110102501" || obj.URL_ID == "110102601" || obj.URL_ID == "310300104")
                    {
                        iv = CryptLib.GenerateRandomIV(16);
                        string key  = CryptLib.getHashSha256("GSWS TEST", 32);
                        string obj2 = GetInputJsonFormat(obj);
                        encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(obj2, key, iv);
                    }
                    else if (obj.URL_ID == "200301401" || obj.URL_ID == "360201701" || obj.URL_ID == "360201401" || obj.URL_ID == "130101101" || obj.URL_ID == "280101201" || obj.URL_ID == "280101401" || obj.URL_ID == "280101301" || obj.URL_ID == "360201801" || obj.URL_ID == "3602018501" || obj.URL_ID == "170100102" || obj.URL_ID == "130101401" || obj.URL_ID == "130101501" || obj.URL_ID == "240200101")
                    {
                        iv = CryptLib.GenerateRandomIV(16);
                        string key  = CryptLib.getHashSha256("GSWS TEST", 32);
                        string obj2 = GetInputJsonFormat(obj);
                        encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(obj2, key, iv);
                    }
                    else
                    {
                    }
                    objdata.status = 200;
                    //objdata.Translist = dt;
                    objdata.encrypttext = encrypttext;
                    objdata.key         = iv;
                    objdata.TransId     = obj.TXN_ID;
                    objdata.Reason      = "Record Inserted Successfully !!!";
                }
                else
                {
                    objdata.status = 400;
                    objdata.Reason = "Failed to Insert Record, Please Try Again !!! ";
                }
            }
            catch (Exception ex)
            {
                objdata.status = 500;
                objdata.Reason = "Something Went Wrong.Please Try Again";                //ex.Message.ToString();
            }

            return(objdata);
        }
Example #28
0
 internal static string getIVkey()
 {
     return(CryptLib.getHashSha256(ConfigurationManager.AppSettings["IVKey"], 16));
 }
Example #29
0
        // Main threading
        void workerUpdate(object sender, DoWorkEventArgs e)
        {
            // TODO: Implement more error handling
            BackgroundWorker sendingworker = (BackgroundWorker)sender;


            // Check variables before starting
            if (String.IsNullOrEmpty(ChosenTempFolder) || String.IsNullOrEmpty(ChosenProjectFolder))
            {
                Application.Current.Dispatcher.Invoke(new Action(() => {
                    new MaterialDialog("", "Please choose both folders.").ShowDialog();
                }));
                e.Cancel = true;
                return;
            }

            // Set up / Clean up variables
            UpdatePackageList = new List <UpdatePackage>();
            HashTable         = new Dictionary <string, HashEntry>();
            mDriveDirectory   = createRootFolder();

            string GameFile          = Path.Combine(ChosenTempFolder, "gamefile.7z");
            string GameFileEncrypted = Path.Combine(ChosenTempFolder, "gamefile.7z.enc");

            // TODO: Ask for information
            // - Versionstring, Description, PatchFor etc.
            // - Set Versionnumber automatically


            askFinalGameName();

            string GameFileFinal = Path.Combine(ChosenTempFolder, FinalGameName);


            sendingworker.ReportProgress(5, new StatusHolder()
            {
                txt = "# Indexing all project files, this might take a while. Please be patient." + Environment.NewLine, progress = -1
            });

            _7zip.CreateZip(ChosenProjectFolder, GameFile, sendingworker);

            if (sendingworker.CancellationPending)
            {
                e.Cancel = true; return;
            }
            sendingworker.ReportProgress(30, new StatusHolder()
            {
                txt = "--> Finished compressing." + Environment.NewLine, progress = -1
            });

            // Encrypt all the packages
            sendingworker.ReportProgress(25, new StatusHolder()
            {
                txt = "# Encrypting the package." + Environment.NewLine, progress = -1
            });

            CryptLib.AES_Encrypt(GameFile, GameFileEncrypted, EncryptionPassword, sendingworker);
            File.Delete(GameFile);
            File.Delete(GameFileFinal);
            File.Move(GameFileEncrypted, GameFileFinal);

            if (sendingworker.CancellationPending)
            {
                e.Cancel = true; return;
            }
            sendingworker.ReportProgress(30, new StatusHolder()
            {
                txt = "--> Finished encrypting." + Environment.NewLine, progress = -1
            });

            // Show notification for the point of no return
            showContinueNotification();
            if (sendingworker.CancellationPending)
            {
                e.Cancel = true; return;
            }

            // Uploading the packages to Google Drive
            sendingworker.ReportProgress(35, new StatusHolder()
            {
                txt = "# Uploading packages to Google Drive", progress = -1
            });
            uploadGame(GameFileFinal, sendingworker);

            if (sendingworker.CancellationPending)
            {
                e.Cancel = true; return;
            }
            sendingworker.ReportProgress(40, new StatusHolder()
            {
                txt = "--> Finished uploading the packages." + Environment.NewLine, progress = -1
            });


            sendingworker.ReportProgress(45, new StatusHolder()
            {
                txt = "# Package uploaded, here's the link:", progress = -1
            });

            // Print out the download url
            string DownloadUrl = "https://drive.google.com/uc?export=download&id=" + UploadedFile.Id;

            sendingworker.ReportProgress(50, new StatusHolder()
            {
                txt = DownloadUrl, progress = -1
            });
            showCopyableText("Here's the download url:", DownloadUrl);

            // Print out the size in bytes
            sendingworker.ReportProgress(55, new StatusHolder()
            {
                txt = "Size in bytes: ", progress = -1
            });
            long Size = new FileInfo(GameFileFinal).Length;

            sendingworker.ReportProgress(60, new StatusHolder()
            {
                txt = Size.ToString(), progress = -1
            });
            showCopyableText("Size in bytes:", Size.ToString());
        }
Example #30
0
        public dynamic OrderDetails(paymentModel obj)
        {
            dynamic objdata = new ExpandoObject();

            try
            {
                obj.orderId = "80120201019362644";

                orderDetailsModel rootobj = new orderDetailsModel();
                rootobj.Amount       = obj.Amount;
                rootobj.Description  = obj.Description;
                rootobj.mobileNumber = obj.mobileNumber;
                rootobj.orderId      = obj.orderId;
                rootobj.totalAmount  = obj.totalAmount;
                rootobj.TxnDate      = obj.TxnDate;
                rootobj.userCharges  = obj.userCharges;
                rootobj.userName     = obj.userName;
                rootobj.walletType   = "";


                DataTable dt1 = gswsPaymentRequestProc(obj, "4", "");
                obj.gswsCode    = dt1.Rows[0][0].ToString();
                obj.UniqueTxnId = obj.merchantId + obj.mobileNumber + DateTime.Now.ToString("yyyyMMddhhmmssmm");

                string json = JsonConvert.SerializeObject(obj);

                string iv  = CryptLib.GenerateRandomIV(16);
                string key = CryptLib.getHashSha256("GSWS TEST", 32);

                string encrypttext = EncryptDecryptAlgoritham.EncryptStringAES(json, key, iv);

                obj.encrypttext = encrypttext;
                obj.iv          = iv;

                rootobj.encrypttext = obj.encrypttext;
                rootobj.iv          = obj.iv;


                if (obj.gswsCode == "10690589" || obj.gswsCode == "10690588" || obj.gswsCode == "10690590" || obj.gswsCode == "21073101")
                {
                    rootobj.walletType = "TA";
                }
                else if (obj.gswsCode == "10690567" || obj.gswsCode == "10690568" || obj.gswsCode == "21073097" || obj.gswsCode == "21073098" || obj.gswsCode == "21073099")
                {
                    rootobj.walletType = "WONE";
                }

                else if (obj.gswsCode == "10690581" || obj.gswsCode == "10690561" || obj.gswsCode == "10690574" || obj.gswsCode == "10690572" || obj.gswsCode == "10690573" || obj.gswsCode == "10690582" || obj.gswsCode == "21073095" || obj.gswsCode == "21073096" || obj.gswsCode == "21073082" || obj.gswsCode == "21073083" || obj.gswsCode == "21073085" || obj.gswsCode == "21073088")
                {
                    rootobj.walletType = "APW";
                }


                DataTable dt = gswsPaymentRequestProc(obj, "1", "");
                if (dt != null && dt.Rows.Count > 0)
                {
                    token_gen.initialize();
                    token_gen.expiry_minutes = 60;
                    token_gen.addClaim("admin");
                    token_gen.PRIMARY_MACHINE_KEY   = "10101010101010101010101010101010";
                    token_gen.SECONDARY_MACHINE_KEY = "1010101010101010";
                    token_gen.addResponse("status", "200");
                    token_gen.addResponse("result", JsonConvert.SerializeObject(rootobj));
                    return(token_gen.generate_token());
                }
                else
                {
                    objdata.status = 400;
                    objdata.result = "Invalid Input";
                    string mappath   = HttpContext.Current.Server.MapPath("gswsPaymentRequestProc.");
                    Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_ReportLog_Exception(mappath, JsonConvert.SerializeObject(obj)));
                }
            }
            catch (Exception ex)
            {
                objdata.status = 500;
                objdata.result = ex.Message.ToString();
            }
            return(objdata);
        }
Example #31
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     lbl_decrypted.Text = CryptLib.Decrypt(txt_decr.Text);
 }
Example #32
0
        // save Services Url's
        public DataTable SaveServices_data_helper(InternalURL obj)
        {
            try
            {
                var comd = new OracleCommand();

                comd.InitialLONGFetchSize = 1000;
                comd.CommandType          = CommandType.StoredProcedure;
                comd.CommandText          = "GSWS_IN_URL_MASTER";
                comd.Parameters.Add("P_TYPE", OracleDbType.Varchar2).Value             = obj.TYPE;
                comd.Parameters.Add("P_SD_ID", OracleDbType.Varchar2).Value            = obj.DEPARTMENT;
                comd.Parameters.Add("P_HOD_ID", OracleDbType.Varchar2).Value           = obj.HOD;
                comd.Parameters.Add("P_SCHEME_ID", OracleDbType.Varchar2).Value        = obj.SERVICE;
                comd.Parameters.Add("P_TYPE_OF_REQUEST", OracleDbType.Varchar2).Value  = obj.REQUESTTYPE;
                comd.Parameters.Add("P_URL_ID", OracleDbType.Varchar2).Value           = obj.URL_ID;
                comd.Parameters.Add("P_URL", OracleDbType.Varchar2).Value              = obj.URL;
                comd.Parameters.Add("P_URL_DESCRIPTION", OracleDbType.Varchar2).Value  = obj.URLDESCRIPTION;
                comd.Parameters.Add("P_ACCESS_LEVEL", OracleDbType.Varchar2).Value     = obj.ACCESSLEVEL;
                comd.Parameters.Add("P_DISTRICT_ID", OracleDbType.Varchar2).Value      = obj.DISTRICT;
                comd.Parameters.Add("P_MANDAL_ID", OracleDbType.Varchar2).Value        = obj.MANDAL;
                comd.Parameters.Add("P_GP_WARD_ID", OracleDbType.Varchar2).Value       = obj.PANCHAYAT;
                comd.Parameters.Add("P_USER_NAME", OracleDbType.Varchar2).Value        = obj.USERNAME;
                comd.Parameters.Add("P_PASSWORD", OracleDbType.Varchar2).Value         = obj.PASSWORD;
                comd.Parameters.Add("P_ENCRYPT_PASSWORD", OracleDbType.Varchar2).Value = string.IsNullOrEmpty(obj.ENCRYPT_PASSWORD) ? null : CryptLib.getHashSha256(obj.ENCRYPT_PASSWORD, 31);;
                comd.Parameters.Add("P_TYPE_OF_SERVICE", OracleDbType.Varchar2).Value  = obj.SERVICETYPE;
                comd.Parameters.Add("P_UR_FLAG", OracleDbType.Varchar2).Value          = obj.RUFLAG;       //
                comd.Parameters.Add("P_URL_DESC_TEL", OracleDbType.Varchar2).Value     = obj.P_URL_DESC_TEL;

                comd.Parameters.Add("DESIGN_R", OracleDbType.Varchar2).Value = obj.RURALDESIGNATION;
                comd.Parameters.Add("DESIGN_U", OracleDbType.Varchar2).Value = obj.URBANDESIGNATION;

                comd.Parameters.Add("P_CUR", OracleDbType.RefCursor).Direction = ParameterDirection.Output;

                DataTable data = GetgswsDataAdapter(comd);
                if (data != null && data.Rows.Count > 0)
                {
                    return(data);
                }
                else
                {
                    return(null);
                }
            }
            catch (WebException wex)
            {
                string mappath   = HttpContext.Current.Server.MapPath("ExceptionLogs");
                Task   WriteTask = Task.Factory.StartNew(() => new Logdatafile().Write_ReportLog_Exception(mappath, "Error Save Services URL data :" + wex.Message.ToString()));
                throw new Exception(wex.Message);
            }
        }
Example #33
0
 public CryptHelper()
 {
     keySha256 = CryptLib.getHashSha256(key, 32); //32 bytes = 256 bits
 }