Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace KaficApp.Logic
  8. {
  9. static partial class PrijavaLogic
  10. {
  11.  
  12. public static int autentifikacijaKorisnika(string korisnickoIme, string lozinka)
  13. {
  14. using (var db = new KaficDB())
  15. {
  16. var query = from korisnici in db.Korisniks orderby korisnici.ID_korisnik select korisnici;
  17.  
  18. foreach (var korisnik in query.ToList<Korisnik>())
  19. {
  20. if(korisnik.Username == korisnickoIme)
  21. {
  22. if(korisnik.Password == lozinka)
  23. {
  24. return korisnik.ID_tip_korisnika;
  25. }
  26. }
  27. }
  28. return 0;
  29. }
  30. }
  31. }
  32. }
  33.  
  34.  
  35. using System;
  36. using System.Collections.Generic;
  37. using System.Linq;
  38. using System.Text;
  39. using System.Threading.Tasks;
  40.  
  41. namespace KaficApp.Logic
  42. {
  43. public class Crypto
  44. {
  45. public static string sha256(string pw)
  46. {
  47. System.Security.Cryptography.SHA256Managed crypt = new System.Security.Cryptography.SHA256Managed();
  48. System.Text.StringBuilder hash = new System.Text.StringBuilder();
  49. byte[] crypto = crypt.ComputeHash(Encoding.UTF8.GetBytes(pw), 0, Encoding.UTF8.GetByteCount(pw));
  50. foreach (byte theByte in crypto)
  51. {
  52. hash.Append(theByte.ToString("x2"));
  53. }
  54. return hash.ToString();
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement