示例#1
0
        public void TestKeccak()
        {
            byte[] input1 = Encoding.HexStringToByteArray("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f");

            byte[] actualOutput1 = Keccak.keccak(input1);

            byte[] expectedOutput1 = Encoding.HexStringToByteArray("8ae1aa597fa146ebd3aa2ceddf360668dea5e526567e92b0321816a4e895bd2d");

            CollectionAssert.AreEqual(expectedOutput1, actualOutput1);

            byte[] input2 = Encoding.HexStringToByteArray("67c6697351ff4aec29cdbaabf2fbe3467cc254f81be8e78d765a2e63339fc99a");

            byte[] actualOutput2 = Keccak.keccak(input2);

            byte[] expectedOutput2 = Encoding.HexStringToByteArray("1968ed1e4a2f6c11cbe2a41b81da9f35fdd3cf5aca60613b7c4b50d0a1071889");

            CollectionAssert.AreEqual(expectedOutput2, actualOutput2);

            byte[] input3 = Encoding.HexStringToByteArray("f71c12de1b8b97205570247a2156a02159654a0fd86caa1661aea266b6de70ad");

            byte[] actualOutput3 = Keccak.keccak(input3);

            byte[] expectedOutput3 = Encoding.HexStringToByteArray("d8b50138c7d6d5c7305b4bbddebe19a9eca5702276bb2427f465a82ee2a40467");

            CollectionAssert.AreEqual(expectedOutput3, actualOutput3);
        }
示例#2
0
        // Test encryption
        static void TestCryptography()
        {
            IHashProvider p;

            // Generate a random set of bytes
            byte[] Bytes = SecureRandom.Bytes(32);

            // Write bytes to console
            Console.WriteLine($"Randomly generated bytes: {Encoding.ByteArrayToHexString(Bytes)}");

            // Keccak the generated bytes
            byte[] KeccakBytes = Keccak.keccak(Bytes);

            // Write keccak bytes to console
            Console.WriteLine($"Keccak: {Encoding.ByteArrayToHexString(KeccakBytes)}");

            // Blake256 the generated bytes
            p = new Blake();
            byte[] BlakeBytes = p.Hash(Bytes);

            // Write blake256 bytes to console
            Console.WriteLine($"Blake: {Encoding.ByteArrayToHexString(BlakeBytes)}");

            // Skein the generated bytes
            p = new Skein();
            byte[] SkeinBytes = p.Hash(Bytes);

            // Write skein bytes to console
            Console.WriteLine($"Skein: {Encoding.ByteArrayToHexString(SkeinBytes)}");

            // Groestl the generated bytes
            p = new Groestl();
            byte[] GroestlBytes = p.Hash(Bytes);

            // Write groestl bytes to console
            Console.WriteLine($"Groestl: {Encoding.ByteArrayToHexString(GroestlBytes)}");

            // JH the generated bytes
            p = new JH();
            byte[] JHBytes = p.Hash(Bytes);

            // Write JH bytes to console
            Console.WriteLine($"JH: {Encoding.ByteArrayToHexString(JHBytes)}");

            // Base58 the generated bytes
            string Base58String = Base58.Encode(Bytes);

            // Write base58 bytes to console
            Console.WriteLine($"Base58: {Base58String}");
            Console.WriteLine();
        }
示例#3
0
        // Test encryption
        static void TestCryptography()
        {
            // Generate a random set of bytes
            byte[] Bytes = SecureRandom.Bytes(32);

            // Write bytes to console
            Console.WriteLine($"Randomly generated bytes: {Encoding.ByteArrayToHexString(Bytes)}");

            // Keccak the generated bytes
            byte[] KeccakBytes = Keccak.keccak(Bytes);

            // Write keccak bytes to console
            Console.WriteLine($"Keccak: {Encoding.ByteArrayToHexString(KeccakBytes)}");

            // Base58 the generated bytes
            string Base58String = Base58.Encode(Bytes);

            // Write base58 bytes to console
            Console.WriteLine($"Base58: {Base58String}");
            Console.WriteLine();
        }