Ejemplo n.º 1
0
        public void Can_read_null()
        {
            PublicKeyConverter converter = new PublicKeyConverter();
            JsonReader         reader    = new JsonTextReader(new StringReader(""));

            reader.ReadAsString();
            PublicKey result = converter.ReadJson(reader, typeof(PublicKey), null, false, JsonSerializer.CreateDefault());

            Assert.AreEqual(null, result);
        }
Ejemplo n.º 2
0
        static void SolveEncryption(string[] args)
        {
            string message         = args[1],
                   publicKeyString = args[2].FromHexString();

            PublicKey publicKey = (PublicKey)PublicKeyConverter.StringToKey(publicKeyString);

            string encryption = rsa.Encrypt(message, publicKey);

            Console.WriteLine(StandardMessages.DisplayEncryptedMessage(encryption));
        }
Ejemplo n.º 3
0
        static void SolveKeyGeneration()
        {
            Console.WriteLine(StandardMessages.GeneratingPrimesInit());
            var sw = new Stopwatch();

            sw.Start();
            var primeNumberGenerator = new PrimeNumberGenerator(keySize / 2);

            sw.Stop();

            int    n = primeNumberGenerator.Primes.Count;
            double t = sw.Elapsed.TotalSeconds;

            Console.WriteLine(StandardMessages.GeneratingPrimesFinish(n, t));

            Console.WriteLine(StandardMessages.GeneratingKeys());
            var keyPair = rsa.GenerateKeyPair(primeNumberGenerator);

            string publicKey  = PublicKeyConverter.KeyToString(keyPair.PublicKey).ToHexString(),
                   privateKey = PrivateKeyConverter.KeyToString(keyPair.PrivateKey).ToHexString();

            Console.WriteLine(StandardMessages.DisplayKeys(publicKey, privateKey));
        }