static void Main(string[] args) { Write("Wpisz tekst do podpisania: "); string dane = ReadLine(); var podpis = Ochrona.GenerujPodpis(dane); WriteLine($"Podpis: {podpis}"); WriteLine("Klucz publiczny:"); WriteLine(Ochrona.KluczPubliczny); if (Ochrona.KontrolaPodpisu(dane, podpis)) { WriteLine("Poprawne"); } else { WriteLine("Podpis niepoprawny"); } var falszywyPodpis = podpis.Replace(podpis[1], 'X'); if (Ochrona.KontrolaPodpisu(dane, falszywyPodpis)) { WriteLine("Poprawne"); } else { WriteLine("Podpis niepoprawny"); } }
static void Main(string[] args) { var alicja = Ochrona.Zarejestruj("Alicja", "H45lo"); WriteLine($"{alicja.Nazwisko}"); WriteLine($"{alicja.Sol}"); WriteLine(alicja.SkrolSolonegoHasla); WriteLine(); bool hasloPrawidlowe = false; while (!hasloPrawidlowe) { Write("Login:"******"haslo"); string haslo = ReadLine(); hasloPrawidlowe = Ochrona.SprawdzHaslo(nazwa, haslo); if (hasloPrawidlowe) { WriteLine("Ok"); } else { WriteLine("Not OK"); } } }
static void Main(string[] args) { WriteLine("Wielkosc klucza: "); string wielkosc = ReadLine(); byte[] klucz = Ochrona.PobierzLosowyKluczWektor(int.Parse(wielkosc)); WriteLine("Klucz:"); for (int i = 0; i < klucz.Length; i++) { Write($"{klucz[i]:x2} "); if (((i + 1) % 16) == 0) { WriteLine(); } } WriteLine(); }
static void Main(string[] args) { Ochrona.Zarejestruj("Alicja", "H45lo", new[] { "Administratorzy" }); Ochrona.Zarejestruj("Bartek", "H45lo", new[] { "Sprzedaz", "Kierownicy" }); Ochrona.Zarejestruj("Ewa", "H45lo"); WriteLine("Login:"******"haslo:"); string haslo = ReadLine(); Ochrona.Zaloguj(nazwaUzytkownika, haslo); if (Thread.CurrentPrincipal == null) { WriteLine("Nie powiodlo sie"); return; } var p = Thread.CurrentPrincipal; WriteLine($"IsAuthentical: {p.Identity.IsAuthenticated}"); WriteLine($"AuthenticalType: {p.Identity.AuthenticationType}"); WriteLine($"Name: {p.Identity.Name}"); WriteLine($"IsInRole(\"Administratorzy\"): {p.IsInRole("Administratorzy")}"); WriteLine($"IsInRole(\"Sprzedaz\"): {p.IsInRole("Sprzedaz")}"); if (p is ClaimsPrincipal) { WriteLine($"{p.Identity.Name} ma :"); foreach (Claim cecha in (p as ClaimsPrincipal).Claims) { WriteLine($"{cecha.Type}: {cecha.Value}"); } } try { Ochrona.FunkcjaWymagaUprawniwn(); //administratora } catch (SystemException ex) { WriteLine(ex.Message); } }
static void Main(string[] args) { Write("Wpisz tekst do szyfrowania: "); string tekst = ReadLine(); Write("Wpisz haslo :"); string haslo = ReadLine(); string tekstZaszyfrowany = Ochrona.Szyfruj(tekst, haslo); WriteLine(tekstZaszyfrowany); Write("Podaj haslo"); string haslo2 = ReadLine(); try { string jawnyTekst = Ochrona.Odszyfruj(tekstZaszyfrowany, haslo2); WriteLine(jawnyTekst); } catch { WriteLine("Zle haslo"); } }