Różnice między wybraną wersją a wersją aktualną.
Poprzednia wersja | |||
— | c-sharp-simplecrypt [2018/07/16 11:47] (aktualna) – edycja zewnętrzna 127.0.0.1 | ||
---|---|---|---|
Linia 1: | Linia 1: | ||
+ | ===== C Sharp - proste szyfrowanie ====== | ||
+ | < | ||
+ | class crypt | ||
+ | { | ||
+ | protected string klucz = " | ||
+ | public string text = ""; | ||
+ | |||
+ | public string tcrypt(string ptext) | ||
+ | { | ||
+ | int x = 0; | ||
+ | text = ""; | ||
+ | int i = 0; | ||
+ | for (x = 0; x < ptext.Length; | ||
+ | { | ||
+ | text += char.ToString((char)(ptext[x] + klucz[i])); | ||
+ | i++; | ||
+ | if (i == klucz.Length) i = 0; | ||
+ | } | ||
+ | return text; | ||
+ | } | ||
+ | |||
+ | public string tcrypt(string ptext, string pklucz) | ||
+ | { | ||
+ | int x = 0; | ||
+ | text = ""; | ||
+ | int i = 0; | ||
+ | for (x = 0; x < ptext.Length; | ||
+ | { | ||
+ | text += char.ToString((char)(ptext[x] + pklucz[i])); | ||
+ | i++; | ||
+ | if (i == pklucz.Length) i = 0; | ||
+ | } | ||
+ | return text; | ||
+ | } | ||
+ | |||
+ | public string tencrypt(string ptext) | ||
+ | { | ||
+ | int x = 0; | ||
+ | text = ""; | ||
+ | int i = 0; | ||
+ | for (x = 0; x < ptext.Length; | ||
+ | { | ||
+ | text += char.ToString((char)(ptext[x] - klucz[i])); | ||
+ | i++; | ||
+ | if (i == klucz.Length) i = 0; | ||
+ | } | ||
+ | return text; | ||
+ | } | ||
+ | |||
+ | public string tencrypt(string ptext, string pklucz) | ||
+ | { | ||
+ | int x = 0; | ||
+ | text = ""; | ||
+ | int i = 0; | ||
+ | for (x = 0; x < ptext.Length; | ||
+ | { | ||
+ | text += char.ToString((char)(ptext[x] - pklucz[i])); | ||
+ | i++; | ||
+ | if (i == pklucz.Length) i = 0; | ||
+ | } | ||
+ | return text; | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ |