Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostChangeEmailAsync()
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'."));
            }

            if (!ModelState.IsValid)
            {
                await LoadAsync(user);

                return(Page());
            }

            var email = await _userManager.GetEmailAsync(user);

            if (Input.NewEmail != Ceasar.Decipher(email, CipherKey))
            {
                var code = await _userManager.GenerateChangeEmailTokenAsync(user, Ceasar.Encipher(Input.NewEmail, CipherKey));

                await ChgangeEmailAndLogout(user, code);

                return(RedirectToAction("Index", "Home"));
            }

            StatusMessage = "Your email is unchanged.";
            return(RedirectToPage());
        }
 private void btnGiaiMaFile_Click(object sender, EventArgs e)
 {
     if (txtPathInputGiaiMa.Text != "")
     {
         if (mnrKeyGiaiMa.Text != "" || txtZGiaima.Text != "")
         {
             dichChuyen_Key = int.Parse(mnrKeyGiaiMa.Text);
             string dichChuyen_Input = inputGiaima;
             string dungluong        = filenameinputGiaima.Split(new char[] { '_' })[1];
             filenameoutputGiaima          = "Decrypt_" + dungluong + "_11.txt";
             filenameoutputGiaimaChallenge = "Decrypt_Challenge" + dungluong + "_11.txt";
             OutputText.Text = Ceasar.Decipher(dichChuyen_Input, dichChuyen_Key, dichChuyen_Z);
             outputGiaima    = Ceasar.Decipher(dichChuyen_Input, dichChuyen_Key, dichChuyen_Z);
             FileHelper.WriteFile(@"" + filenameoutputGiaima + "", "Di chuyển", dichChuyen_Z, dichChuyen_Key.ToString(), outputGiaima);
             txtOutputGiaiMaName.Text = System.IO.Path.GetFileName(@"" + filenameoutputGiaima + "");
             FileHelper.WriteFile(@"" + filenameoutputGiaimaChallenge + "", "Di chuyển", dichChuyen_Z, outputGiaima);
             txtOutputGiaiMaChallengeName.Text = System.IO.Path.GetFileName(@"" + filenameoutputGiaimaChallenge + "");
         }
         else
         {
             MessageBox.Show("Chưa nhập đủ thông tin!!!");
         }
     }
     else
     {
         MessageBox.Show("Chưa chọn file để giải mã");
     }
 }
Ejemplo n.º 3
0
        private async Task LoadAsync(IdentityUser user)
        {
            var email = await _userManager.GetEmailAsync(user);

            Email = Ceasar.Decipher(email, CipherKey);

            Input = new InputModel
            {
                NewEmail = Ceasar.Decipher(email, CipherKey)
            };

            IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user);
        }
Ejemplo n.º 4
0
        private async Task LoadAsync(IdentityUser user)
        {
            var userName = await _userManager.GetUserNameAsync(user);

            var phoneNumber = await _userManager.GetPhoneNumberAsync(user);

            Username = Ceasar.Decipher(userName, CipherKey);

            Input = new InputModel
            {
                PhoneNumber = phoneNumber
            };
        }
 private void btnGiaiMa_Click(object sender, EventArgs e)
 {
     if (txtK.Text != "" && txtZ.Text != "")
     {
         dichChuyen_Key = int.Parse(txtK.Text);
         dichChuyen_Z   = txtZ.Text;
     }
     else
     {
         MessageBox.Show("Chưa nhập đủ thông tin!!");
         return;
     }
     OutputText.Text = Ceasar.Decipher(InputText.Text, dichChuyen_Key, dichChuyen_Z);
 }
Ejemplo n.º 6
0
        private void ExcuteAlgorithm()
        {
            _result = new List <string>();
            int algor    = cbxAlgorithm.SelectedIndex;
            int progress = cbxProgress.SelectedIndex;

            switch (algor)
            {
            case 0:
                int key = int.Parse(rtbxKey.Text);
                if (progress == 0)
                {
                    foreach (var item in _data)
                    {
                        _result.Add(Ceasar.Encipher(item, key));
                    }
                }
                else
                {
                    foreach (var item in _data)
                    {
                        _result.Add(Ceasar.Decipher(item, key));
                    }
                }
                break;

            case 1:
                string khoa = rtbxKey.Text;
                if (progress == 0)
                {
                    foreach (var item in _data)
                    {
                        _result.Add(Playfair.PlayfairEncryption(item, khoa));
                    }
                }
                else
                {
                    foreach (var item in _data)
                    {
                        _result.Add(Playfair.PlayfairDecryption(item, khoa));
                    }
                }
                break;
            }
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Index()
        {
            var allUsers   = _userManager.Users.ToList();
            var allUsersVM = new List <IdentityUserViewModel>();

            foreach (var user in allUsers)
            {
                var roles = await _userManager.GetRolesAsync(user);

                var role = roles.FirstOrDefault();
                IdentityUserViewModel identityUserVM = new IdentityUserViewModel
                {
                    Id       = user.Id,
                    UserName = Ceasar.Decipher(user.UserName, CipherKey),
                    Role     = role
                };
                allUsersVM.Add(identityUserVM);
            }
            return(View(allUsersVM));
        }
Ejemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            String ka      = textBox1.Text;
            String string1 = "";

            try
            {
                // tao instance cua StreamReader de doc mot file.
                // lenh using cung duoc su dung de dong StreamReader.
                using (StreamReader sr = new StreamReader(ka))
                {
                    string line;

                    // doc va hien thi cac dong trong file cho toi
                    // khi tien toi cuoi file.
                    while ((line = sr.ReadLine()) != null)
                    {
                        string1 = string1 + line;
                        Console.WriteLine(line);
                    }
                }

                Console.ReadKey();
            }
            catch (Exception g)
            {
                // thong bao loi.
                Console.WriteLine("Khong the doc du lieu tu file da cho: ");
                Console.WriteLine(g.Message);
            }
            //sao chep
            string stringz = @"abcdefghijklmnopqrstuvwxyz";
            int    t0      = 0;
            string tr0;

            tr0 = Ceasar.Decipher(string1, t0, stringz);
            string tr1 = "";

            tr1 = Ceasar.Decipher(string1, 1, stringz);
            string tr2 = "";

            tr2 = Ceasar.Decipher(string1, 2, stringz);
            string tr3 = "";

            tr3 = Ceasar.Decipher(string1, 3, stringz);
            string tr4 = "";

            tr4 = Ceasar.Decipher(string1, 4, stringz);

            string tr5 = "";

            tr5 = Ceasar.Decipher(string1, 5, stringz);
            string tr6 = "";

            tr6 = Ceasar.Decipher(string1, 6, stringz);
            string tr7 = "";

            tr7 = Ceasar.Decipher(string1, 7, stringz);
            string tr8 = "";

            tr8 = Ceasar.Decipher(string1, 8, stringz);
            string tr9 = "";

            tr9 = Ceasar.Decipher(string1, 9, stringz);
            string tr10 = "";

            tr10 = Ceasar.Decipher(string1, 10, stringz);
            string tr11 = "";

            tr11 = Ceasar.Decipher(string1, 11, stringz);
            string tr12 = "";

            tr12 = Ceasar.Decipher(string1, 12, stringz);
            string tr13 = "";

            tr13 = Ceasar.Decipher(string1, 13, stringz);
            string tr14 = "";

            tr14 = Ceasar.Decipher(string1, 14, stringz);
            string tr15 = "";

            tr15 = Ceasar.Decipher(string1, 15, stringz);
            string tr16 = "";

            tr16 = Ceasar.Decipher(string1, 16, stringz);
            string tr17 = "";

            tr17 = Ceasar.Decipher(string1, 17, stringz);
            string tr18 = "";

            tr18 = Ceasar.Decipher(string1, 18, stringz);
            string tr19 = "";

            tr19 = Ceasar.Decipher(string1, 19, stringz);
            string tr20 = "";

            tr20 = Ceasar.Decipher(string1, 20, stringz);
            string tr21 = "";

            tr21 = Ceasar.Decipher(string1, 21, stringz);
            string tr22 = "";

            tr22 = Ceasar.Decipher(string1, 22, stringz);
            string tr23 = "";

            tr23 = Ceasar.Decipher(string1, 23, stringz);
            string tr24 = "";

            tr24 = Ceasar.Decipher(string1, 24, stringz);
            string tr25 = "";

            tr25 = Ceasar.Decipher(string1, 25, stringz);
            string tr26 = "";

            tr26           = Ceasar.Decipher(string1, 26, stringz);
            textBox2.Text  = tr0;
            textBox3.Text  = tr1;
            textBox4.Text  = tr2;
            textBox5.Text  = tr3;
            textBox6.Text  = tr4;
            textBox7.Text  = tr5;
            textBox8.Text  = tr6;
            textBox9.Text  = tr7;
            textBox10.Text = tr8;
            textBox11.Text = tr9;
            textBox12.Text = tr10;
            textBox13.Text = tr11;
            textBox14.Text = tr12;
            textBox15.Text = tr13;
            textBox16.Text = tr14;
            textBox17.Text = tr16;
            textBox18.Text = tr17;
            textBox19.Text = tr18;
            textBox20.Text = tr19;
            textBox21.Text = tr20;
            textBox22.Text = tr21;
            textBox23.Text = tr22;
            textBox24.Text = tr23;
            textBox25.Text = tr24;
            textBox26.Text = tr25;
            textBox27.Text = tr26;
        }