예제 #1
0
        public static void ChangeAccountPassword(RegistratrionFormConstruct registratrionFormConstruct)
        {
            FileInfo      fileInfo      = new FileInfo("F:/SAUGUMO TEST CHAMBER4/PasswordSystemFiles/AccountList.txt.aes");
            AesEcnryption aesEcnryption = new AesEcnryption();

            aesEcnryption.FileDecryption(fileInfo);
            FileInfo info = new FileInfo(fileInfo.FullName.Replace(".aes", ""));
            List <LoginValidationConstructcs> loginValidationConstructcs = new List <LoginValidationConstructcs>();

            //  LoginValidationConstructcs loginValidationConstructcs = new LoginValidationConstructcs();
            foreach (string line in File.ReadAllLines(fileInfo.FullName.Replace(".aes", "")))
            {
                string[] splitString = line.Split(",");
                loginValidationConstructcs.Add(new LoginValidationConstructcs(splitString[0], splitString[1]));
            }
            foreach (LoginValidationConstructcs constructcs in loginValidationConstructcs)
            {
                if (constructcs.username.Equals(registratrionFormConstruct.name, StringComparison.Ordinal))
                {
                    Argon2 argon2 = new Argon2();
                    constructcs.hashValue = argon2.Argon2Impl(registratrionFormConstruct.password);
                }
            }
            File.Create(fileInfo.FullName.Replace(".aes", "")).Dispose();
            List <string> inputList = new List <string>();

            foreach (LoginValidationConstructcs login in loginValidationConstructcs)
            {
                string input = login.username + "," + login.hashValue;
                inputList.Add(input);
            }
            File.AppendAllLines(info.FullName, inputList);
            aesEcnryption.FileEncryption(info);
        }
예제 #2
0
        // SALT - fjH!wa+OAC#P*Avu
        public RegistratrionFormConstruct PassowrdHashing(RegistratrionFormConstruct registratrionFormConstruct)
        {
            string hash = Argon2Impl(registratrionFormConstruct.password);

            registratrionFormConstruct.passwordHash = hash;
            return(registratrionFormConstruct);
        }
예제 #3
0
 private void addButton1_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(nameBox.Text) && !String.IsNullOrWhiteSpace(pswBox.Text) &&
         !String.IsNullOrWhiteSpace(appBox.Text) && !String.IsNullOrWhiteSpace(commBox.Text))
     {
         RegistratrionFormConstruct registratrionFormConstruct = new RegistratrionFormConstruct(nameBox.Text, pswBox.Text, appBox.Text, commBox.Text);
         AesEcnryption ecnryption = new AesEcnryption();
         registratrionFormConstruct.password = ecnryption.PasswordEncryption(registratrionFormConstruct.password);
         LogedInScreen.userPasswordList.Add(registratrionFormConstruct);
     }
     else
     {
         MessageBox.Show("Please Fill out the form properly");
     }
 }
예제 #4
0
 private void registerButton_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(nameBox.Text) && !String.IsNullOrWhiteSpace(passwordBox.Text) &&
         !String.IsNullOrWhiteSpace(applicationBox.Text) && !String.IsNullOrWhiteSpace(commentBox.Text))
     {
         RegistratrionFormConstruct registratrionFormConstruct = new RegistratrionFormConstruct(nameBox.Text, passwordBox.Text, applicationBox.Text, commentBox.Text);
         AesEcnryption ecnryption = new AesEcnryption();
         registratrionFormConstruct.password = ecnryption.PasswordEncryption(registratrionFormConstruct.password);
         // MessageBox.Show($"encrypted :{registratrionFormConstruct.password}");
         //  ecnryption.PasswordDecryption(Convert.FromBase64String(registratrionFormConstruct.password));
         //   MessageBox.Show($"Decrypted :{ecnryption.PasswordDecryption(Convert.FromBase64String(registratrionFormConstruct.password))}");
         Argon2 argon2 = new Argon2();
         registratrionFormConstruct = argon2.PassowrdHashing(registratrionFormConstruct);
         FileSystemUtility fileSystemUtility = new FileSystemUtility();
         fileSystemUtility.RegistrationAndEncryption(registratrionFormConstruct);
     }
     else
     {
         MessageBox.Show("Please Fill out the form properly");
     }
 }
예제 #5
0
        public void RegistrationAndEncryption(RegistratrionFormConstruct registratrionFormConstruct)
        {
            AesEcnryption aesEcnryption = new AesEcnryption();
            string        filepath      = "F:/SAUGUMO TEST CHAMBER4/PasswordSystemFiles/AccountList.txt";
            string        fileInput     = registratrionFormConstruct.name +
                                          "," + registratrionFormConstruct.passwordHash;
            FileInfo fileInfo = new FileInfo(filepath);

            if (File.Exists(fileInfo.FullName + ".aes"))
            {
                FileInfo accountList = new FileInfo(fileInfo.FullName + ".aes");
                aesEcnryption.FileDecryption(accountList);
                foreach (string s in File.ReadAllLines(fileInfo.FullName))
                {
                    string[] comparison = s.Split(',');
                    if (comparison[0].Equals(registratrionFormConstruct.name, StringComparison.Ordinal))
                    {
                        MessageBox.Show("Such user allready exists");
                        aesEcnryption.FileEncryption(fileInfo);
                        return;
                    }
                }
            }
            string dirPath = "F://SAUGUMO TEST CHAMBER4//PasswordSystemFiles";

            Directory.CreateDirectory(dirPath);
            File.Create("F:/SAUGUMO TEST CHAMBER4/PasswordSystemFiles/" + registratrionFormConstruct.name + ".txt").Dispose();
            string inputStr = registratrionFormConstruct.name + "," + registratrionFormConstruct.password +
                              "," + registratrionFormConstruct.application + "," + registratrionFormConstruct.comment;

            File.WriteAllLines("F:/SAUGUMO TEST CHAMBER4/PasswordSystemFiles/" + registratrionFormConstruct.name + ".txt", new[] { inputStr });
            FileInfo userFile = new FileInfo("F:/SAUGUMO TEST CHAMBER4/PasswordSystemFiles/" + registratrionFormConstruct.name + ".txt");

            aesEcnryption.FileEncryption(userFile);

            File.AppendAllLines(filepath, new[] { fileInput });

            aesEcnryption.FileEncryption(fileInfo);
        }