Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace sofa4 {
- class Program {
- static long gamma = 137438691328;
- static long cur_gamma = gamma;
- static void Main(string[] args) {
- string a = "привет, мир!";
- string b = Shifr(a);
- string c = Deshifr(b);
- Console.WriteLine(a);
- Console.WriteLine(b);
- Console.WriteLine(c);
- }
- static string Shifr(string message) {
- cur_gamma = gamma;
- StringBuilder ret = new StringBuilder(message.ToLower().Replace('ё', 'е'));
- for (int i = 0; i < ret.Length; ++ i) {
- int c = Convert.ToInt32(ret[i]);
- if (c < 1072 || c > 1103) continue;
- c = (c - 1072 + (int)(cur_gamma % 10)) % 32 + 1072;
- ret[i] = Convert.ToChar(c);
- cur_gamma /= 10;
- if (cur_gamma == 0) cur_gamma = gamma;
- }
- return ret.ToString();
- }
- static string Deshifr(string message) {
- cur_gamma = gamma;
- StringBuilder ret = new StringBuilder(message.ToLower().Replace('ё', 'е'));
- for (int i = 0; i < ret.Length; ++ i) {
- int c = Convert.ToInt32(ret[i]);
- if (c < 1072 || c > 1103) continue;
- c = (c - 1072 + 32 - (int)(cur_gamma % 10)) % 32 + 1072;
- ret[i] = Convert.ToChar(c);
- cur_gamma /= 10;
- if (cur_gamma == 0) cur_gamma = gamma;
- }
- return ret.ToString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement