Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.InputEncoding  = Encoding.Unicode;
            Console.OutputEncoding = Encoding.Unicode;
            var generator = new DiffiHelmanGenerator(2002681, 34657434);
            var alice     = new Client(generator);
            var bob       = new Client(generator);

            bob.InitPrivateKey(alice.GetPublicKey());
            alice.InitPrivateKey(bob.GetPublicKey());

            var clipper = new XORCipher();

            Console.WriteLine("Введите текст для шифрования");
            var text = Console.ReadLine();

            var encoded = clipper.Encrypt(text, bob.Key.ToString());

            Console.WriteLine($"encoded {encoded}");

            var decoded = clipper.Decrypt(encoded, alice.Key.ToString());

            Console.WriteLine($"decoded {decoded}");
        }
Exemplo n.º 2
0
 public Client(DiffiHelmanGenerator generator)
 {
     Generator = generator;
     this.Seed = Generator.GetRandom();
 }