Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            Write("Enter some text to sign: ");
            string data      = ReadLine();
            var    signature = Protector.GenerateSignature(data);

            WriteLine($"Signature: {signature}");
            WriteLine("Public key used to check signature:");
            WriteLine(Protector.PublicKey);
            if (Protector.ValidateSignature(data, signature))
            {
                WriteLine("Correct! Signature is valid.");
            }
            else
            {
                WriteLine("invalid signature.");
            }

            //make a fake signature
            var fakeSignature = signature.Replace(signature[0], 'X');

            if (Protector.ValidateSignature(data, fakeSignature))
            {
                WriteLine("Correct! signature is valid.");
            }
            else
            {
                WriteLine($"Invalid signature: {fakeSignature}");
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Write("Enter some text to sign: ");
            string userInput = ReadLine();

            var signature = Protector.GenerateSignature(userInput);

            WriteLine($"Signature: {signature}");
            WriteLine("\nPublic key used to check signature:");
            WriteLine(Protector.PublicKey);

            if (Protector.ValidateSignature(userInput, signature))
            {
                WriteLine("\nCorrect! Signature is valid.");
            }
            else
            {
                WriteLine("\nInvalid signature.");
            }


            // simulate a fake signature by replacing the first character with an X
            // var fakeSignature = signature.Replace(signature[0], 'X');
            // if (Protector.ValidateSignature(userInput, fakeSignature))
            // {
            //     WriteLine("\nCorrect! Signature is valid.");
            // }
            // else
            // {
            //     WriteLine($"\nInvalid signature: {fakeSignature}");
            // }
        }
        static void Main(string[] args)
        {
            Write("Enter some text to sign: ");
            string data      = ReadLine();
            var    signature = Protector.GenerateSignature(data);

            WriteLine($"Signature: {signature}");
            WriteLine("Public key used to check signature:");
            WriteLine(Protector.PublicKey);

            if (Protector.ValidateSignature(data, signature))
            {
                WriteLine("Correct! Signature is valid.");
            }
            else
            {
                WriteLine("Invalid signature.");
            }

            // create a fake signature by replacing the
            // first character with an X
            var fakeSignature = signature.Replace(signature[0], 'X');

            if (Protector.ValidateSignature(data, fakeSignature))
            {
                WriteLine("Correct! Signature is valid.");
            }
            else
            {
                WriteLine($"Invalid signature: {fakeSignature}");
            }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            Write("Enter some text to sign: ");
            string data      = ReadLine();
            var    signature = Protector.GenerateSignature(data);

            WriteLine($"Signature : {signature}");
            WriteLine($"Publick key used to check signature:");
            WriteLine(Protector.PublickKey);

            if (Protector.ValidateSignature(data, signature))
            {
                WriteLine("Correct! Signature is valid");
            }
            else
            {
                WriteLine("Invalid signature");
            }

            // Создаём поддельную подпись, заменив первый символ на Х
            var fakeSignature = signature.Replace(signature[0], 'X');

            if (Protector.ValidateSignature(data, fakeSignature))
            {
                WriteLine("Correct! Signature is valid");
            }
            else
            {
                WriteLine($"Invalid signature: {fakeSignature}");
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Write("Enter some text to sign: ");
            string data      = ReadLine();
            var    signature = Protector.GenerateSignature(data);

            WriteLine($"Signature: {signature}");
            WriteLine("Public key used to check signature:");
            WriteLine(Protector.PublicKey);

            if (Protector.ValidateSignature(data, signature))
            {
                WriteLine("Correct! Signature is valid.");
            }
            else
            {
                WriteLine("Invalid signature.");
            }

            // 첫 번째 문자를 X로 바꿔서 잘못된 서명을 만든다.
            var fakeSignature = signature.Replace(signature[0], 'X');

            if (Protector.ValidateSignature(data, fakeSignature))
            {
                WriteLine("Correct! Signature is valid.");
            }
            else
            {
                WriteLine($"Invalid signature: {fakeSignature}");
            }
        }
Ejemplo n.º 6
0
        static void CheckSignature()
        {
            Console.Write("Enter some text to sign: ");
            string data      = Console.ReadLine();
            var    signature = Protector.GenerateSignature(data);

            Console.WriteLine($"Signature: {signature}");
            Console.WriteLine("Public key used to check signature:");
            Console.WriteLine(Protector.PublicKey);
            if (Protector.ValidateSignature(data, signature))
            {
                Console.WriteLine("Correct! Signature is valid.");
            }
            else
            {
                Console.WriteLine("Invalid signature.");
            }

            var fakeSignature = signature.Replace(signature[0], 'X');

            if (Protector.ValidateSignature(data, fakeSignature))
            {
                Console.WriteLine("Correct! Signature is valid.");
            }
            else
            {
                Console.WriteLine($"Invalid signature: {fakeSignature}");
            }
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            WriteLine("Enter some text to sign: ");
            string inputText = ReadLine();
            var    signature = Protector.GenerateSignature(inputText);

            WriteLine($"Signature: {signature}");
            WriteLine($"Public key used to check signature: \n{Protector.PublicKey}");

            if (Protector.ValidateSignature(inputText, signature))
            {
                WriteLine($"Signature is valid :-)");
            }
            else
            {
                WriteLine($"Signature is NOT valid :-(");
            }

            // simulate a fake signature, replace first char with an X
            var fakeSignature = signature.Replace(signature[0], 'X');

            if (Protector.ValidateSignature(inputText, fakeSignature))
            {
                WriteLine($"Using fakeSignature...signature is valid :-)");
            }
            else
            {
                WriteLine($"Using fakeSignature...signature is NOT valid :-(...the fake signature is: \n{fakeSignature}");
            }
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            Write("Enter some text to sign: ");
            string data      = ReadLine();
            var    signature = Protector.GenerateSignature(data);

            WriteLine($"Signature: {signature}");
            WriteLine("Public key used to check signature:");
            WriteLine(Protector.PublicKey);

            if (Protector.ValidateSignature(data, signature))
            {
                WriteLine("Correct! Signature is valid.");
            }
            else
            {
                WriteLine("Invalid signature.");
            }
        }
Ejemplo n.º 9
0
        private static void Main(string[] args)
        {
            //encrypting and adding a signature so other people can know its us
            Write("Enter some text to sign: ");
            var data      = ReadLine();
            var signature = Protector.GenerateSignature(data);

            WriteLine($"Signature: {signature}");
            WriteLine("Public key used to check signature:");
            WriteLine(Protector.PublicKey);

            WriteLine(Protector.ValidateSignature(data, signature)
                ? "Correct! Signature is valid."
                : "Invalid signature.");

            // simulate a fake signature by replacing the
            // first character with an X
            var fakeSignature = signature.Replace(signature[0], 'X');

            WriteLine(Protector.ValidateSignature(data, fakeSignature)
                ? "Correct! Signature is valid."
                : $"Invalid signature: {fakeSignature}");
        }