0

I want to add the Variables userName and encryptedPass to column 1 and 2 on the Users Table of my "SongRater" database. The database is set up and functional. I've tried a few solutions but haven't found any that work for my specific situation.

private void button4_Click_1(object sender, EventArgs e)
    {
        //ensures passwords match
        if (textBox4.Text == textBox5.Text)
        {
            //encrypts password using username as key
            string userName = textBox3.Text;
            string passToEncrypt = textBox4.Text;
            VignereCipher v = new VignereCipher();
            string s0 = passToEncrypt;
            string pw = userName;
            string encryptedPass = v.encrypt(s0, pw, 1);

            //adds username and encrypted password to SQL database
            //not sure what to do here

            //confirms user added and closes user create form
            MessageBox.Show("user successfully added!");
            this.Close();
        }
        else
        {
            MessageBox.Show("Password does not match confirmed password");
        }
    }

the SQL Table is here, and again the database name is "SongRater". I know how to use SQL to add records to a database, which is all I'm trying to do here (also setup the UserID value to increase by one for each user in the table)

 CREATE TABLE Passwords
 (
     UserID INT IDENTITY(1,1) PRIMARY KEY,
     UserName VARCHAR(15) NOT NULL,
     ScrambledPass VARCHAR(25) NOT NULL,
 )

I want to add C# string userName to the userName column, and add C# string encryptedPass to the ScrambledPass column. Any recommended resources on how to do this using the windows form button would be greatly appreciated, or any quick solutions.

Thom A
  • 88,727
  • 11
  • 45
  • 75
Poyo
  • 1
  • 1
    Your situation isn't special, you will be able to find plenty of resources online. In my opinion, [Dapper](https://www.jetbrains.com/dotnet/guide/tutorials/basics/dapper/) might be a good place for you to start. – Crowcoder Apr 07 '22 at 17:58
  • A Vignere cipher is a bad choice because it can be reversed (decoded - it's not encryption, by the way). You should salt and hash the password, and store that instead. – madreflection Apr 07 '22 at 18:07

0 Answers0