Advertisement
Guest User

Untitled

a guest
Feb 6th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using Hash;
  12.  
  13.  
  14. namespace WindowsFormsApplication1
  15. {
  16. public partial class frmLogin : Form
  17. {
  18.  
  19. public string salt = "dfoidfhjo&dfkf%$dfik/";
  20.  
  21. public frmLogin()
  22. {
  23. InitializeComponent();
  24. }
  25.  
  26. private void frmLogin_Load(object sender, EventArgs e)
  27. {
  28.  
  29. }
  30.  
  31. private void textBox1_TextChanged(object sender, EventArgs e)
  32. {
  33.  
  34. }
  35.  
  36. private void label1_Click(object sender, EventArgs e)
  37. {
  38.  
  39. }
  40.  
  41. private void label1_Click_1(object sender, EventArgs e)
  42. {
  43.  
  44. }
  45.  
  46. private void Password_TextChanged(object sender, EventArgs e)
  47. {
  48.  
  49. }
  50.  
  51. private void btnLogin_Click(object sender, EventArgs e)
  52. {
  53.  
  54. if (txtUsername.Text.Length < 4 || txtPassword.Text.Length < 4)
  55. {
  56. MessageBox.Show(String.Format("The Username or the Password is wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error));
  57.  
  58. }
  59. else
  60. {
  61. if (!Directory.Exists($"/data/users/{txtUsername.Text}"))
  62. {
  63. MessageBox.Show(String.Format("The Username or the Password is wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error));
  64.  
  65. }
  66. else
  67. {
  68.  
  69. StreamReader sr = new StreamReader($"/data/users/{txtUsername.Text}/data.ls");
  70. string user = sr.ReadLine();
  71. string passhash = sr.ReadLine();
  72. sr.Close();
  73.  
  74. string thispass = SHA1.Hashing(SHA1.Hashing(txtPassword.Text + salt));
  75.  
  76. if (user = txtUsername.Text && passhash == thispass)
  77. {
  78.  
  79.  
  80.  
  81.  
  82. }
  83.  
  84. else
  85. {
  86. MessageBox.Show(String.Format("The Username or the Password is wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error));
  87. }
  88.  
  89. }
  90.  
  91.  
  92.  
  93. string username = txtUsername.Text.Trim();
  94. string password = txtPassword.Text;
  95. }
  96. }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement