Advertisement
Guest User

Untitled

a guest
Sep 5th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. var salt = "FbSnXHPo12gb";
  2. var password = "geheim";
  3.  
  4. var interactions = 12000;
  5.  
  6.  
  7. using (var hmac = new HMACSHA256())
  8. {
  9. var df = new Pbkdf2(hmac, password, salt, interactions);
  10. Console.WriteLine(Convert.ToBase64String(df.GetBytes(32)));
  11. }
  12.  
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Threading.Tasks;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. using System.Windows.Data;
  21. using System.Windows.Documents;
  22. using System.Windows.Input;
  23. using System.Windows.Media;
  24. using System.Windows.Media.Imaging;
  25. using System.Windows.Navigation;
  26. using System.Windows.Shapes;
  27. using MySql.Data.MySqlClient;
  28. using System.IO;
  29. using System.Security.Cryptography;
  30.  
  31.  
  32. namespace login
  33. {
  34.  
  35. /// <summary>
  36. /// Interaction logic for MainWindow.xaml
  37. /// </summary>
  38. public partial class MainWindow : Window
  39. {
  40.  
  41. public MainWindow()
  42. {
  43. InitializeComponent();
  44. }
  45.  
  46. private void login_Click(object sender, RoutedEventArgs e)
  47. {
  48.  
  49. var salt = "FbSnXHPo12gb";
  50. var password = "geheim";
  51. var interactions = 12000;
  52.  
  53.  
  54. using (var hmac = new HMACSHA256())
  55. {
  56. var df = new Pbkdf2(hmac, password, salt, interactions);
  57. Console.WriteLine(Convert.ToBase64String(df.GetBytes(32)));
  58. }
  59.  
  60. string myConnection = "datasource=localhost;port=3306;username=root;password=abcde12345 ; database=finalproject";
  61. MySqlConnection myConn = new MySqlConnection(myConnection);
  62. MySqlCommand SelectCommand = new MySqlCommand("select * from login where Username='" + this.username.Text + "' and Password='" + this.password.Password + "';", myConn);
  63. MySqlDataReader myReader;
  64. myConn.Open();
  65. myReader = SelectCommand.ExecuteReader();
  66. int count = 0;
  67. while (myReader.Read())
  68. {
  69. count = count + 1;
  70. }
  71. if (count == 1)
  72. {
  73. MessageBox.Show("Hello");
  74.  
  75. }
  76.  
  77. else
  78. {
  79.  
  80. MessageBox.Show("Wrong username and password");
  81. }
  82. myConn.Close();
  83. }
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement