Esempio n. 1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            clsUserLoginManage objUserLogin = new clsUserLoginManage();
            dtoUser            objUser      = new dtoUser();
            string             UserName     = EncDec.Encrypt(txtuserid.Text, DbConnect.AdminKey);
            string             Password     = EncDec.Encrypt(txtpassword.Text, DbConnect.AdminKey);

            DataTable dt = objUserLogin.GetLogin(UserName, Password);

            if (dt.Rows.Count > 0)
            {
                objUser.AUTO_ID      = dt.Rows[0]["AUTO_ID"].ToString();
                objUser.USER_ID      = EncDec.Decrypt(dt.Rows[0]["USER_ID"].ToString(), DbConnect.AdminKey);
                objUser.USER_TYPE    = Convert.ToInt32(dt.Rows[0]["USER_TYPE"].ToString());
                Session["AdminUser"] = objUser;

                if (Session["AdminUser"] != null)
                {
                    Response.Redirect("Home.aspx");
                }
            }
            else
            {
                Session["AdminUser"] = null;
            }
        }
        catch (Exception ex)
        {
            Page.RegisterStartupScript("aa", "<script>alert('" + ex.Message + "');</script>");
        }
    }
Esempio n. 2
0
        public string EncodeString(MemoryStream Lock, string Data)
        {
            Lock.Position = 0;
            var key = DecodeLock(Lock);

            return(EncDec.Encrypt(Data, key));
        }
Esempio n. 3
0
        protected void btnSignIn_Click(object sender, EventArgs e)
        {
            string strUsername = txtUsername.Text.Trim();
            string strPassword = txtPassword.Text;

            strPassword = EncDec.Encrypt(strPassword);
            dbVASEntities OdbVAS = new dbVASEntities();

            var lUserLogin = OdbVAS.tbl_User.Where(l => l.Username == strUsername && l.Password == strPassword && l.IsActive == true).Select(l => new { l.FName, l.LName, l.Username, l.IsDataAdmin, l.IsItemAdmin, l.IsMale, l.Mobile, l.UserPhoto, l.IsReal }).FirstOrDefault();

            if (lUserLogin == null)
            {
                Bootstrap_Callout.Display     = true;
                Bootstrap_Callout.ShowWarning = true;
                Bootstrap_Callout.Message     = "نام کاربری یا گذرواژه نامعتبر است";
            }
            else
            {
                Service.Security.stcUserInfo sobjUserInfo;
                sobjUserInfo.FName       = lUserLogin.FName;
                sobjUserInfo.LName       = lUserLogin.LName;
                sobjUserInfo.Username    = lUserLogin.Username;
                sobjUserInfo.UserPhoto   = lUserLogin.UserPhoto;
                sobjUserInfo.Mobile      = lUserLogin.Mobile;
                sobjUserInfo.IsItemAdmin = lUserLogin.IsItemAdmin;
                sobjUserInfo.IsDataAdmin = lUserLogin.IsDataAdmin;
                sobjUserInfo.IsMale      = lUserLogin.IsMale;
                sobjUserInfo.IsReal      = lUserLogin.IsReal;

                Session["stcUserInfo"] = sobjUserInfo;

                FormsAuthentication.SetAuthCookie("VAS_Username", false);
                Response.Redirect("~/Application/WebForm1.aspx");
            }
        }
Esempio n. 4
0
        public static string encode_passwd(string user, string passwd)
        {
            byte[] numArray = new byte[4];
            new Random().NextBytes(numArray);
            string hex = clib.byte_to_hex(numArray, 4);

            return("{enc}" + hex + EncDec.Encrypt(passwd, hex + UserDb.dbkey));
        }
Esempio n. 5
0
        private void fbLogin(HttpContext context)
        {
            string token = context.Request.Params["token"];

            Facebook.FacebookClient client = new Facebook.FacebookClient(token);
            //client.Post()
            client.UseFacebookBeta = client.IsSecureConnection = true;
            Facebook.JsonObject o = (Facebook.JsonObject)client.Get("/me");
            var db = new PetaPoco.Database(Common.HairStyleConnectionString, "System.Data.SqlClient");

            using (var scope = db.GetTransaction())
            {
                try
                {
                    string         first_name = (string)o["first_name"];
                    string         name       = (string)o["name"];
                    decimal        id         = Convert.ToDecimal(o["id"]);
                    POCOS.Facebook fb         = new POCOS.Facebook();
                    fb.name       = name;
                    fb.first_name = first_name;
                    fb.gender     = (string)o["gender"];
                    fb.id         = id;
                    fb.last_name  = (string)o["last_name"];
                    fb.link       = (string)o["link"];
                    fb.locale     = (string)o["locale"];
                    fb.timezone   = Convert.ToDouble(o["timezone"]);
                    string   updatedtime = (string)o["updated_time"];
                    DateTime dt;
                    if (DateTime.TryParse(updatedtime, out dt))
                    {
                        fb.updated_time = dt;
                    }
                    if (db.Exists <POCOS.Facebook>(id))
                    {
                        db.Update(fb);
                    }
                    else
                    {
                        db.Insert(fb);
                    }
                    POCOS.AppUser au = POCOS.AppUser.FirstOrDefault("Select top 1 * from AppUsers where facebookid=@0", id);
                    if (au == null)
                    {
                        au            = new POCOS.AppUser();
                        au.FirstName  = first_name;
                        au.facebookid = id;
                        db.Insert(au);
                    }
                    scope.Complete();
                    CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = au.ID }), Common.DefaultPassword), false);
                    CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = au.Email, name = au.Name, avatar = string.IsNullOrWhiteSpace(au.Avatar) ? null : Common.UploadedImageRelPath + au.Avatar }), false);
                }
                finally
                {
                    scope.Dispose();
                }
            }
        }
Esempio n. 6
0
        string EncryptWithStack(List <BaseLock> Stack, string Value)
        {
            var result = Value;

            foreach (var s in Stack)
            {
                result = EncDec.Encrypt(result, s.GetKey());
            }
            return(result);
        }
Esempio n. 7
0
        private void Login(HttpContext context)
        {
            string user = context.Request.Params["user"];
            string pass = context.Request.Params["pass"];

            Nails.edmx.User obj = this.GetNailsProdContext.User.FirstOrDefault(o => o.Name == user && o.Password == pass);
            if (obj != null)
            {
                CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { obj.ID }), Common.DefaultPassword), false);
                CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { obj.Name }), false);
                context.Response.Write("success");
            }
        }
Esempio n. 8
0
        private void Invite(HttpContext context)
        {
            string invite = context.Request.QueryString["s"];

            if (!string.IsNullOrEmpty(invite))
            {
                PindexProd.dbml.AppUsers au = GetPindexProdContext2.AppUsers.FirstOrDefault(o1 => o1.Invite == invite);
                if (au != null)
                {
                    CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = au.ID }), Common.DefaultPassword), false);
                    CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = au.Email, name = au.Name, avatar = string.IsNullOrWhiteSpace(au.Avatar) ? null : Common.UploadedImageRelPath + au.Avatar }), false);
                    context.Response.Redirect("~/home#settings", false);
                }
            }
        }
Esempio n. 9
0
        /// <summary> Common constructor logic </summary>
        private Client()
        {
            this.id = Guid.NewGuid();
            tcpReadState.Initialize();
            udpReadState.Initialize();

            tcpOutgoing = new ConcurrentQueue <string>();
            udpOutgoing = new ConcurrentQueue <string>();

            {             // Temp encryption
                EncDec encryptor = new EncDec();
                Crypt  e         = (b) => encryptor.Encrypt(b);
                Crypt  d         = (b) => encryptor.Decrypt(b);
                SetEncDec(e, d);
                //enc = e;
                //dec = d;
            }
        }
Esempio n. 10
0
 private void SaveProfile(HttpContext context)
 {
     Nails.edmx.AppUsers u = this.GetNailsProdContext.AppUsers.First(o => o.ID == Common.UserID);
     if (string.IsNullOrEmpty(u.Password))
     {
         context.Response.WriteError("Password not updated");
     }
     else
     {
         string email      = context.Request.Params["email"];
         string first_name = context.Request.Params["first_name"];
         string about      = context.Request.Params["about"];
         string location   = context.Request.Params["location"];
         string fn         = context.Request.Params["fn"];
         string website    = context.Request.Params["website"];
         string name       = context.Request.Params["name"];
         if (!string.IsNullOrEmpty(fn))
         {
             Uri      uri          = new Uri(fn);
             string   filename     = uri.Segments.Last();
             string   fp           = Path.Combine(Common.Temp, Common.UserID.ToString(), filename);
             string   uploadedpath = Common.UploadedImagePath;
             FileInfo fInfo        = new FileInfo(fp);
             string   nfn          = fInfo.Name;
             if (fInfo.DirectoryName != uploadedpath)
             {
                 string dest = Path.Combine(uploadedpath, nfn);
                 fInfo.MoveTo(dest);
             }
             u.Avatar = nfn;
         }
         u.Location  = location;
         u.Email     = email;
         u.FirstName = first_name;
         u.Website   = website;
         u.Location  = location;
         u.About     = about;
         u.Name      = name;
         GetNailsProdContext.SaveChanges();
         CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = u.ID }), Common.DefaultPassword), false);
         CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new { email = u.Email, name = u.Name, avatar = string.IsNullOrWhiteSpace(u.Avatar) ? null : Common.UploadedImageRelPath + u.Avatar }), false);
     }
 }
 /// <summary>
 /// Exports the content of the collection in a file selected by the user
 /// </summary>
 public void Export(ImportExportData data)
 {
     try
     {
         if (!data.Encrypt)
         {
             this.SqlConnections.Serialize(data.FileName);
         }
         else
         {
             EncDec.Encrypt(this.mSqlConnections.Serialize(), data.FileName);
         }
     }
     catch (Exception ex)
     {
         EventLogger.SendMsg(ex);
         throw;
     }
 }
Esempio n. 12
0
        protected void GenerateString()
        {
            strMessage = bmp.Calculate();
            key        = txtKey.Text;
            merchantID = txtMerchantID.Text;
            EncDec aesEncrypt = new EncDec();

            requestparams1      = aesEncrypt.Encrypt(key, strMessage);
            requestparams.Value = merchantID + "||NI||" + requestparams1;
            txtVerify.Text      = strMessage;
            string path = Server.MapPath("~/log/Log.txt");

            using (System.IO.StreamWriter writer = new System.IO.StreamWriter(path, true))
            {
                writer.WriteLine(strMessage);
                writer.WriteLine("After encryption ...");
                writer.WriteLine(requestparams.Value);
                writer.Close();
            }
        }
Esempio n. 13
0
        public async Task <HttpResponseMessage> ChangePassword(UserChangePassDto userChangePassDto)
        {
            //var oResultDto = new ResultDto();
            var intUserID      = Setting.payloadDto.userId;
            var strPassword    = EncDec.Encrypt(userChangePassDto.currentPassword);
            var strNewPassword = EncDec.Encrypt(userChangePassDto.newPassword);

            bool blnChangedPassword = await _AccountingService.checkAndUpdateUserPassword(intUserID, strPassword, strNewPassword);

            if (blnChangedPassword)
            {
                return(new HttpResponseMessage(HttpStatusCode.OK));
            }
            //oResultDto.resultCode = "200";
            else
            {
                return(new HttpResponseMessage(HttpStatusCode.NotModified));
            }
            //oResultDto.resultCode = "404";
        }
Esempio n. 14
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            using (var db = new bigshopeEntities())
            {
                var query = db.loginCustomer(tbUser.Text, EncDec.Encrypt(tbPassword.Text)).ToList();

                if (query.Count > 0)
                {
                    Session["customer_id"] = query[0].customer_id;
                    Session["email"]       = query[0].customer_email;
                    Session.Timeout        = 720;

                    Response.Redirect("profile.aspx");
                }
                else
                {
                    lblLoginStatus.Text = "Invalid username or password";
                }
            }
        }
Esempio n. 15
0
        private static void Main(string[] args)
        {
            EncDec.Encrypt("Build_Test.exe", "Build_Test.exe.dec", "test");

            EncDec.Decrypt("Build_Test.exe.dec", "Build_Test.dec.exe", "test");


            Console.Read();
            Environment.Exit(-1);
            string original = System.Text.Encoding.Unicode.GetString(File.ReadAllBytes("Build_Test.exe"));

            // Create a new instance of the Aes
            // class.  This generates a new key and initialization
            // vector (IV).
            using (Aes myAes = Aes.Create())
            {
                // Encrypt the string to an array of bytes.
                byte[] encrypted = Aes_Example.AesExample.EncryptStringToBytes_Aes(original, myAes.Key, myAes.IV);

                // Decrypt the bytes to a string.
                string roundtrip = Aes_Example.AesExample.DecryptStringFromBytes_Aes(encrypted, myAes.Key, myAes.IV);

                File.WriteAllBytes("Build_Test.exe.dec", encrypted);

                var dec = File.ReadAllBytes("Build_Test.exe.dec");

                string final = Aes_Example.AesExample.DecryptStringFromBytes_Aes(dec, myAes.Key, myAes.IV);

                File.WriteAllBytes("Build_Test.dec.exe", Encoding.Unicode.GetBytes(original));
                //Display the original data and the decrypted data.
                Console.WriteLine("Original:   {0}\n\n", original);
                Console.WriteLine("Round Trip: {0}", final);
            }



            //
            //Aes_Example.AesExample.start();
            Console.Read();
        }
Esempio n. 16
0
        private void AppLogin(HttpContext context)
        {
            string user  = context.Request.Params["user"];
            string pass  = context.Request.Params["pass"];
            string match = Common.GetHash(pass);
            var    obj   = (from o in GetHairStyleContext2.AppUsers
                            where (o.Email == user || o.Name == user) && o.Password == match
                            select new
            {
                o.Email,
                o.Name,
                o.Avatar,
                o.ID
            }).SingleOrDefault();

            if (obj == null)
            {
                context.Response.Write("Invalid Email Address and/or Password");
            }
            else
            {
                CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = obj.ID }), Common.DefaultPassword), false);
                CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new
                {
                    email  = obj.Email,
                    name   = obj.Name,
                    avatar = string.IsNullOrWhiteSpace(obj.Avatar) ? null : Common.UploadedImageRelPath + obj.Avatar
                }), false);
                GetHairStyleContext3.UpdatePoints(obj.ID, Common.SessionID).Execute();
                JObject jobj   = JObject.Parse(context.Server.UrlDecode(CookieUtil.ReadCookie(Common.sessioncookie)));
                int?    points = (from o in GetHairStyleContext4.AppUsers where o.ID == obj.ID select o.Points).First();
                var     ids    = (from o in GetHairStyleContext4.Reviews where o.ID == obj.ID select o.BIMID);
                jobj["pts"] = JObject.FromObject(new
                {
                    ids,
                    total = points
                });
                CookieUtil.WriteCookie(Common.sessioncookie, jobj.ToString(), false);
            }
        }
Esempio n. 17
0
        public async Task <JasonWebTokenDto> Login(UserLoginDto userLoginDto)
        {
            string strPassword = EncDec.Encrypt(userLoginDto.password);
            string strUsername = userLoginDto.username;

            var oUserDto = await _AccountingService.getAndCheckLoginUser(strUsername, strPassword);

            if (oUserDto == null)
            {
                return(null);
            }
            //  oResult.resultCode = "404";
            //  oResult.userInfo = null;
            //  oResult.menutitlesDto = null;
            //  oResult.resultCode = "200";
            // oResult.userInfo = oUserDto;
            //  Session["UserInfo"] = oUserDto;

            var oPayloadDto = new PayloadDto()
            {
                expireDate  = DateTime.Now.AddMinutes(Setting.JWT_TIMEOUT_MINUTE).Ticks,
                companyId   = oUserDto.companyId,
                isDataAdmin = oUserDto.isDataAdmin,
                isItemAdmin = oUserDto.isItemAdmin,
                userId      = oUserDto.id,
            };

            var strJsonSecurityToken = new JavaScriptSerializer().Serialize(oPayloadDto);
            var strEncryptedJson     = EncDec.Encrypt(strJsonSecurityToken);

            return(new JasonWebTokenDto()
            {
                JWT = strEncryptedJson,
            });

            //var oMenutitlesDto = _AccountingService.getMenutitles(oUserDto.id, oUserDto.isItemAdmin);
            // Session["Menutitles"] = oMenutitlesDto;

            //         oResult.resultCode = "200";
        }
Esempio n. 18
0
        private void AppLogin(HttpContext context)
        {
            string user  = context.Request.Params["user"];
            string pass  = context.Request.Params["pass"];
            string match = Common.GetHash(pass);

            SubSonic.POCOS.AppUser obj = SubSonic.POCOS.AppUser.SingleOrDefault(o => o.Email == user);
            if (obj == null)
            {
                context.Response.WriteError("無效的電子郵件地址和/或密碼");
            }
            else
            {
                CookieUtil.WriteCookie(Common.AuthCookie, EncDec.Encrypt(JsonConvert.SerializeObject(new { ID = obj.ID }), Common.DefaultPassword), false);
                CookieUtil.WriteCookie(Common.InfoCookie, JsonConvert.SerializeObject(new
                {
                    email  = obj.Email,
                    name   = obj.Name,
                    avatar = string.IsNullOrWhiteSpace(obj.Avatar) ? null : Common.UploadedImageRelPath + obj.Avatar
                }), false);
            }
        }
Esempio n. 19
0
        public static void _Encrypt()
        {
            var temp_file = Path.GetFileNameWithoutExtension(file) + ".dec.temp";

            EncDec.Encrypt(file, temp_file, passwd);

            plaintext = fullsize("User:"******"  MachineName:" + Environment.MachineName) + fullsize(Path.GetExtension(file));

            encryptedstring = Encryption.EncryptString(plaintext, passwd);


            var new_Path = Path.GetDirectoryName(file) + "\\" + Path.GetFileNameWithoutExtension(file) + ".dec";

            File.Create(new_Path).Close();

            var temp = StringExtensions.SplitInParts(encryptedstring, name.Length);

            string finalstring = "";

            foreach (var item in temp)
            {
                finalstring += item + "\n";
            }

            //Console.WriteLine(name + "\n" + finalstring + name);

            if (finalstring.Length > 128)
            {
                Console.WriteLine("expectete error!");
            }

            var byte1 = Encoding.ASCII.GetBytes(name + finalstring);
            var byte2 = File.ReadAllBytes(temp_file);
            var byte3 = Encoding.ASCII.GetBytes(name);


            byte[] bytes = new byte[byte1.Length + byte2.Length + byte3.Length];

            int t = 0;

            for (int i = t; i < byte1.Length; i++)
            {
                bytes[i] = byte1[i - t];
            }
            t += byte1.Length;
            for (int i = t; i < byte2.Length + t; i++)
            {
                bytes[i] = byte2[i - t];
            }
            t += byte2.Length;
            for (int i = t; i < byte3.Length + t; i++)
            {
                bytes[i] = byte3[i - t];
            }
            t += byte3.Length;

            //not hapend
            if (t != bytes.Length)
            {
                Console.WriteLine("fatal error: {0},{1}", t, bytes.Length);
            }


            File.WriteAllBytes(new_Path, bytes);
            Console.WriteLine("Written all to: " + new_Path);
            Ende();
        }
Esempio n. 20
0
 public static void __Encrypt()
 {
     EncDec.Encrypt(file, file + ".dec", passwd);
     Ende();
 }
Esempio n. 21
0
        public static string GetFolderProfileUser()
        {
            string strPath = "";

            try
            {
                strPath = HttpContext.Current.Request.PhysicalApplicationPath + string.Format(ResourcePathUrl.Folder_Temp_User, EncDec.Encrypt(HttpContext.Current.Session["loginid"].ToString()), HttpContext.Current.Session["userid"].ToString(), HttpContext.Current.Session.SessionID);
                _logger.Info(strPath);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(strPath);
        }
        /// <summary>
        /// Returns an encrypted string containing the data of this control.
        /// </summary>
        /// <returns></returns>
        public string GetEncryptedData()
        {
            string jSonData = this.SqlConnections.Serialize();

            return(EncDec.Encrypt(jSonData));
        }
        /// <summary>
        /// Saves the data encrypting them in the specified file.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <exception cref="NoConnectionDataFileException"></exception>
        private void SaveEncrypted(string fileName)
        {
            string jSonData = this.SqlConnections.Serialize();

            EncDec.Encrypt(jSonData, fileName);
        }
Esempio n. 24
0
        public static string CreateFolderTempControllerProfile(string controllerName)
        {
            string strPath = "";

            try
            {
                string strProfileUser = string.Format(ResourcePathUrl.Folder_Temp_User, EncDec.Encrypt(HttpContext.Current.Session["loginid"].ToString()), HttpContext.Current.Session["userid"].ToString(), HttpContext.Current.Session.SessionID);
                strPath = Functions.MapPath(string.Format("/{0}Controllers/{1}/", strProfileUser, controllerName));

                if (!Directory.Exists(strPath))
                {
                    Directory.CreateDirectory(strPath);
                }

                _logger.Info(strPath);
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
            }
            return(strPath);
        }
        protected void btnCheckOut_Click(object sender, EventArgs e)
        {
            var gateway = new StripeGateway("sk_test_Biqolmcf9wmzviLy2J0xHfjg");

            var cardToken = gateway.Post(new CreateStripeToken
            {
                Card = new StripeCard
                {
                    Name           = tbFName.Text + tbLName.Text,
                    Number         = tbCardNo.Text,
                    Cvc            = tbCVC.Text,
                    ExpMonth       = Convert.ToInt32(tbMonth.Text),
                    ExpYear        = Convert.ToInt32(tbYear.Text),
                    AddressLine1   = tbAddress.Text,
                    AddressLine2   = tbAddress.Text,
                    AddressZip     = tbCity.Text,
                    AddressState   = tbState.Text,
                    AddressCountry = "Pakistan",
                },
            });

            var customer = gateway.Post(new CreateStripeCustomerWithToken
            {
                Card        = cardToken.Id,
                Description = "Purchasing Purpose",
                Email       = tbEmail.Text,
            });
            var temp   = customer.Id;
            var charge = gateway.Post(new ChargeStripeCustomer
            {
                Amount      = 100 * 10,
                Customer    = customer.Id,
                Currency    = "usd",
                Description = "Test Charge Customer",
            });


            using (var db = new bigshopeEntities())
            {
                tblCustomer cus = new tblCustomer();
                cus.customer_name     = tbFName.Text;
                cus.customer_surname  = tbLName.Text;
                cus.customer_email    = tbEmail.Text;
                cus.customer_phone    = tbPhone.Text;
                cus.customer_address  = tbAddress.Text;
                cus.customer_city     = tbCity.Text;
                cus.customer_address  = tbAddress.Text;
                cus.customer_city     = tbCity.Text;
                cus.customer_state    = tbState.Text;
                cus.customer_zip      = Convert.ToInt32(tbPost.Text);
                cus.customer_password = EncDec.Encrypt(tbPass.Text);
                //cus.customer_stripe_id = "sk_test_Biqolmcf9wmzviLy2J0xHfjg";
                cus.customer_stripe_id = temp;
                db.tblCustomers.Add(cus);
                db.SaveChanges();

                // Order Insertion
                tblOrder order = new tblOrder();
                order.order_prod_id      = 1;
                order.order_total_amount = Request.Cookies["grandTotal"].Value.ToString();
                order.order_time         = DateTime.Now;
                db.tblOrders.Add(order);
                db.SaveChanges();

                //sendMail();

                Response.Redirect("thanks_for_shopping.aspx");
            }
        }
Esempio n. 26
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            int i = drpDwnReversalType.SelectedIndex;

            switch (i)
            {
            case 0:
                break;

            case 1:
            {
                string strMessage = txtReferenceNumber.Text;        // + "|";
                EncDec aesEncrypt = new EncDec();
                strMessage = aesEncrypt.Encrypt(txtKey.Text, strMessage);
                string result = EncDec.Decrypt(txtKey.Text, clientObj.InvokeVoidWS(txtMerchantID.Text, strMessage));
                txtResult.Text = result;
                Decode(result, voidKeys);
                break;
            }

            case 2:
            {
                string strMessage = txtReferenceNumber.Text;        // + "|";
                EncDec aesEncrypt = new EncDec();
                strMessage = aesEncrypt.Encrypt(txtKey.Text, strMessage);
                string decry  = clientObj.InvokeFullAuthReversalWS(txtMerchantID.Text, strMessage);
                string result = EncDec.Decrypt(txtKey.Text, decry);
                txtResult.Text = result;
                Decode(result, fullAuthKeys);
                break;
            }

            case 3:
            {
                string strMessage = txtReferenceNumber.Text;        // + "|"+ txtAmount.Text + "|";
                EncDec aesEncrypt = new EncDec();
                strMessage = aesEncrypt.Encrypt(txtKey.Text, strMessage);
                string result = EncDec.Decrypt(txtKey.Text, clientObj.InvokeCaptureWS(txtMerchantID.Text, strMessage));
                txtResult.Text = result;
                Decode(result, captureKeys);
                break;
            }

            case 4:
            {
                amountRow.Visible = true;
                string strMessage = txtReferenceNumber.Text;        // + "|";
                EncDec aesEncrypt = new EncDec();
                strMessage = aesEncrypt.Encrypt(txtKey.Text, strMessage);
                string amount = aesEncrypt.Encrypt(txtKey.Text, txtAmount.Text);
                string result = EncDec.Decrypt(txtKey.Text, clientObj.InvokePartialCaptureWS(txtMerchantID.Text, strMessage, amount));
                txtResult.Text = result;
                Decode(result, partialCaptureKeys);
                break;
            }

            case 5:
            {
                amountRow.Visible = true;
                string strMessage = txtReferenceNumber.Text;        // + "|";
                EncDec aesEncrypt = new EncDec();
                strMessage = aesEncrypt.Encrypt(txtKey.Text, strMessage);
                string amount = aesEncrypt.Encrypt(txtKey.Text, txtAmount.Text);
                string result = EncDec.Decrypt(txtKey.Text, clientObj.InvokeReversalWS(txtMerchantID.Text, strMessage, amount));
                txtResult.Text = result;
                Decode(result, reversalKeys);
                break;
            }
            }
        }
Esempio n. 27
0
        protected void Session_End(object sender, EventArgs e)
        {
            try
            {
                if (Functions.CheckSession(Session["loginid"], "string"))
                {
                    LoginServices service = new LoginServices();
                    service.LogoutHistory(Session["loginid"].ToString(), Session["sessionid"].ToString());

                    //set thuoc tinh de xoa thu muc trong sessiong end
                    PropertyInfo p       = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
                    object       o       = p.GetValue(null, null);
                    FieldInfo    f       = o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
                    object       monitor = f.GetValue(o);
                    MethodInfo   m       = monitor.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic);
                    m.Invoke(monitor, new object[] { });
                    //delete folder
                    DirectoryInfo dirRemove = new DirectoryInfo(string.Format("{0}/Profiles/{1}/Temps/{2}_{3}", Application["dirCache"], EncDec.Encrypt(Session["loginid"].ToString()), Session["userid"].ToString(), Session.SessionID));
                    if (dirRemove.Exists)
                    {
                        dirRemove.Delete(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Log4Net logger = new Log4Net("Global");
                logger.Error(ex);
            }
        }
Esempio n. 28
0
        protected void btnEncrypt_Click(object sender, EventArgs e)
        {
            //Harcoded merchant key

            //string key = "QN3PFOQ+PKSU8pWThKXq9t4mLxcCCwyvi7+cvj/h4H0=";

            string key = "K7MCfw+AFMN1HEKmhATQzK2HT5eiFymimN9eu+Yb95s=";

            string strMessage = txtOrdNo.Text;

            strMessage += txtMerchantOrderNumber.Text + "|" +
                          txtCurrency.Text + "|" +
                          txtAmount.Text + "|" +
                          txtSuccessURL.Text + "|" +
                          txtFailureURL.Text + "|" +
                          txtTransactionType.Text + "|" +
                          txtTransactionMode.Text + "|" +
                          txtPayModeType.Text + "|" +
                          txtCreditCardNumber.Text + "|" +
                          txtCVV.Text + "|" +
                          txtExpiryMonth.Text + "|" +
                          txtExpiryYear.Text + "|" +
                          txtCardType.Text + "|" +
                          txtBillToFirstName.Text + "|" +
                          txtBillToLastName.Text + "|" +
                          txtBillToStreet1.Text + "|" +
                          txtBillToStreet2.Text + "|" +
                          txtBillToCity.Text + "|" +
                          txtBillToState.Text + "|" +
                          txtBillToPostalCode.Text + "|" +
                          txtBillToCountry.Text + "|" +
                          txtBillToEmail.Text + "|" +
                          txtBillToPhoneNumber1.Text + "|" +
                          txtBillToPhoneNumber2.Text + "|" +
                          txtBillToPhoneNumber3.Text + "|" +
                          txtBillToMobileNumber.Text + "|" +
                          txtGatewayID.Text + "|" +
                          txtCustomerID.Text + "|" +
                          txtShipToFirstName.Text + "|" +
                          txtShipToLastName.Text + "|" +
                          txtShipToStreet1.Text + "|" +
                          txtShipToStreet2.Text + "|" +
                          txtShipToCity.Text + "|" +
                          txtShipToState.Text + "|" +
                          txtShipToPostalCode.Text + "|" +
                          txtShipToCountry.Text + "|" +
                          txtShipToPhoneNumber1.Text + "|" +
                          txtShipToPhoneNumber2.Text + "|" +
                          txtShipToPhoneNumber3.Text + "|" +
                          txtShipToMobileNumber.Text + "|" +
                          txtTransactionSource.Text + "|" +
                          txtProductInfo.Text + "|" +
                          txtIsUserLoggedIn.Text + "|" +
                          txtItemTotal.Text + "|" +
                          txtItemCategory.Text + "|" +
                          txtIgnoreValidationResult.Text + "|" +
                          txtudf1.Text + "|" +
                          txtudf2.Text + "|" +
                          txtudf3.Text + "|" +
                          txtudf4.Text + "|" +
                          txtudf5.Text + "|";

            EncDec aesEncrypt = new EncDec();

            requestparams1 = aesEncrypt.Encrypt(key, strMessage);



            /***Merchant ID is concatenated with encrypted requestparameter****/
            requestparams.Value = "201703301000001|" + requestparams1;
            txtVerify.Text      = requestparams1;
            //TextBox5.Text = requestparams.Value;
        }
Esempio n. 29
0
        public Client(TcpClient tcpClient, Server server = null)
        {
            if (server == null)
            {
                server = Server.NullInstance;
            }
            this.server = server;
            this.id     = Guid.NewGuid();
            this.tcp    = tcpClient;
            tcpReadState.Initialize();
            udpReadState.Initialize();

            var remoteEndPoint = tcpClient.Client.RemoteEndPoint;
            var localEndpoint  = tcpClient.Client.LocalEndPoint;

            Log.Info($"\\eClient \\y {identity}\\e connected from \\y {localEndpoint} -> {remoteEndPoint}");
            if (remoteEndPoint is IPEndPoint && localEndpoint is IPEndPoint)
            {
                IPEndPoint remoteIpep = remoteEndPoint as IPEndPoint;
                IPEndPoint localIpep  = localEndpoint as IPEndPoint;
                remoteIP   = remoteIpep.Address.ToString();
                remotePort = remoteIpep.Port;
                localIP    = localIpep.Address.ToString();
                localPort  = localIpep.Port;

                int localUdpPort  = localPort + 1;
                int remoteUdpPort = remotePort + 1;
                localUdpHost  = new IPEndPoint(remoteIpep.Address, localUdpPort);
                remoteUdpHost = new IPEndPoint(remoteIpep.Address, remoteUdpPort);

                try {
                    udp = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                    // Note: May need this if there are disconnections due to ICMP errors.
                    // const int SIO_UDP_CONNRESET = -1744830452;
                    // udp.IOControl((IOControlCode)SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 },  null);
                    if (isMaster)
                    {
                        udp.Bind(localUdpHost);
                    }
                    Log.Info($"{identity} UDP Connected to {localUdpHost} ==> {remoteUdpHost}");
                } catch (Exception e) {
                    Log.Warning($"{identity} Failed to bind UDP. Disabling UDP.", e);
                    udp = null;
                }
            }
            else
            {
                remoteIP   = "????";
                remotePort = -1;
                localIP    = "????";
                localPort  = -1;
                Log.Info($"{identity} UDP Unconnected.");
            }
            tcpStream.ReadTimeout  = DEFAULT_READWRITE_TIMEOUT;
            tcpStream.WriteTimeout = DEFAULT_READWRITE_TIMEOUT;

            tcpOutgoing = new ConcurrentQueue <string>();
            udpOutgoing = new ConcurrentQueue <string>();

            {             // Temp encryption
                EncDec encryptor = new EncDec();
                Crypt  e         = (b) => encryptor.Encrypt(b);
                Crypt  d         = (b) => encryptor.Decrypt(b);
                SetEncDec(e, d);
                //enc = e;
                //dec = d;
            }
        }
Esempio n. 30
0
        public string cipherDataS(string login, string password, string dataToCipher)
        {
            string key = computeAESSkey(login, password);

            EncDec aes = new EncDec();
            string ciphered = aes.Encrypt(dataToCipher, key);

            return ciphered;
        }
        public static string DoEncrypt(string dataToEncrypt, string FileNames, string _entropy)
        {
            if (string.IsNullOrWhiteSpace(_entropy))
            {
                _entropy = EntropyGenerator.GetIPForMachine();
            }

            if (string.IsNullOrWhiteSpace(FileNames))
            {
                FileName = Application.StartupPath + @"\Data.txt";
            }
            else
            {
                FileName = FileNames;
            }

            //Write to file
            if (File.Exists(Application.StartupPath + @"\dataToEncrypt.txt"))
            {
                System.IO.File.Delete(Application.StartupPath + @"\dataToEncrypt.txt");
            }
            System.IO.File.WriteAllText(Application.StartupPath + @"\dataToEncrypt.txt", dataToEncrypt);
            EncDec.Encrypt(Application.StartupPath + @"\dataToEncrypt.txt", FileName, _entropy);
            System.IO.File.Delete(Application.StartupPath + @"\dataToEncrypt.txt");

            //EncDec.Decrypt(@"C:\Users\224702\Desktop\Sample1.txt", @"C:\Users\224702\Desktop\Sample2.txt", @"127.0.0.1");

            /*
             * entropy = UnicodeEncoding.ASCII.GetBytes(_entropy.ToCharArray(), 0, 16);
             * IV = UnicodeEncoding.ASCII.GetBytes(Reverse(_entropy).ToCharArray(), 0, 16);
             *
             * // Create a new instance of the Aes
             * // class.  This generates a new key and initialization
             * // vector (IV).
             * encryptedData = dataToEncrypt;
             * FileName = FileNames;
             *
             * FileStream stream = new FileStream(FileName,
             * FileMode.OpenOrCreate,FileAccess.Write);
             *
             * Aes cryptic = Aes.Create();
             * //cryptic.Padding = PaddingMode.None;
             * cryptic.Key = entropy;
             * cryptic.IV = IV;
             *
             * // Create a decrytor to perform the stream transform.
             *  ICryptoTransform decryptor = cryptic.CreateEncryptor(entropy, IV);
             *
             * CryptoStream crStream = new CryptoStream(stream,
             * decryptor, CryptoStreamMode.Write);
             *
             *
             * byte[] data = ASCIIEncoding.ASCII.GetBytes(dataToEncrypt);
             *
             * crStream.Write(data,0,data.Length);
             *
             * crStream.Close();
             * stream.Close();
             *
             *
             *  // Encrypt the string to an array of bytes.
             * //        byte[] encrypted = EncryptStringToBytes_Aes(dataToEncrypt,
             * //entropy,IV);
             *
             * //              string roundtrip = DecryptStringFromBytes_Aes(encrypted,
             * //entropy, IV);
             *
             *
             *
             *
             *
             *
             *
             *
             *
             * //if(_entropy != null)
             * //    entropy = UnicodeEncoding.ASCII.GetBytes(_entropy);
             * //DoEncrypt();*/
            return(FileName);
        }