private void button3_Click_1(object sender, EventArgs e) { Cryptography cryptography = new Cryptography(); String value = "Ala ma kota i psa"; /* byte[] encrypt = cryptography.AESEncryption(value);*/ string encrypt = cryptography.AESEncryption(value); /* Console.WriteLine("Encrypt : " + Encoding.UTF8.GetString(encrypt, 0, encrypt.Length));*/ String result = cryptography.AESDecryption(encrypt); Console.WriteLine("Result decrypt text : " + result); cryptography.EncryptSHA512(value); }
private void ButtonInsert_Click(object sender, EventArgs e) { Cryptography c = new Cryptography(); DataBase dataBase = new DataBase(); HashPassword = c.AESEncryption(textPassword.Text); /* Console.WriteLine("HAshcode 1" + Encoding.ASCII.GetString(HashPassword));*/ dataBase.AddPassword(textTitle.Text, textlogin.Text, HashPassword, textWebAddress.Text, textDesc.Text, Files.filePath); listView1.Items.Add(new ListViewItem(new string[] { textTitle.Text, textlogin.Text, HashPassword, textWebAddress.Text, textDesc.Text })); string decodePassword = c.AESDecryption(HashPassword); Console.WriteLine("Odszyfrowane hasło: " + decodePassword); }
public bool AddPassword(string title, string login, string password, string webAddress, string descryption, String filePath = "") { Cryptography cryptography = new Cryptography(); try { using (SQLiteConnection connection = new SQLiteConnection(@"DataSource=" + filePath)) { string hashPass = cryptography.AESEncryption(password); /*string passwordStr = Encoding.ASCII.GetString(hashPass);*/ SQLiteCommand command = new SQLiteCommand("insert into passwords (title,login,password,web_address,description,owner) values (@title, @login, @password, @web,@desc,@owner)", connection); connection.Open(); command.Parameters.AddWithValue("@login", login); /* command.Parameters.AddWithValue("@password", passwordStr);*/ command.Parameters.AddWithValue("@password", hashPass); command.Parameters.AddWithValue("@login", login); command.Parameters.AddWithValue("@title", title); command.Parameters.AddWithValue("@web", webAddress); command.Parameters.AddWithValue("@desc", descryption); command.Parameters.AddWithValue("@owner", DataBase.loginCurrentUser); command.ExecuteScalar(); Console.WriteLine(command.CommandText); /* connection.Close();*/ return(true); } }catch (SqliteException sqlite) { Console.Error.WriteLine(sqlite.Message); return(false); } catch (Exception excpe) { Console.Error.WriteLine(excpe.Message); return(false); } }