コード例 #1
0
        public void IHashFunction_Extensions_ComputeHash_WithDesiredBits_byteArray()
        {
            var hashFunction = new JenkinsOneAtATime();

            var knownValues = new Dictionary <int, byte[]>()
            {
                { 1, new byte[] { 0x00 } },
                { 2, new byte[] { 0x02 } },
                { 4, new byte[] { 0x09 } },
                { 8, new byte[] { 0x1a } },
                { 16, new byte[] { 0xb5, 0x04 } },
                { 32, new byte[] { 0xe7, 0xfd, 0x52, 0xf9 } },
                { 48, new byte[] { 0xcb, 0x66, 0x52, 0xf9, 0x70, 0xac } },
                { 53, new byte[] { 0x3e, 0xf9, 0x52, 0xf9, 0x70, 0xac, 0x0c } },
                { 55, new byte[] { 0xd1, 0xfc, 0x52, 0xf9, 0x70, 0xac, 0x2c } },
                { 64, new byte[] { 0xe7, 0xfd, 0x52, 0xf9, 0x70, 0xac, 0x2c, 0x9b } },
            };


            foreach (var knownValue in knownValues)
            {
                Assert.Equal(
                    knownValue.Value,
                    hashFunction.ComputeHash(
                        TestConstants.FooBar,
                        knownValue.Key));
            }
        }
コード例 #2
0
        public void IHashFunction_Extensions_ComputeHash_WithDesiredBits_byteArray()
        {
            var hashFunction = new JenkinsOneAtATime();

            var knownValues = new Dictionary<int, byte[]>() {
                {  1, new byte[] { 0x00 } },
                {  2, new byte[] { 0x02 } },
                {  4, new byte[] { 0x09 } },
                {  8, new byte[] { 0x1a } },
                { 16, new byte[] { 0xb5, 0x04 } },
                { 32, new byte[] { 0xe7, 0xfd, 0x52, 0xf9 } },
                { 48, new byte[] { 0xcb, 0x66, 0x52, 0xf9, 0x70, 0xac } },
                { 53, new byte[] { 0x3e, 0xf9, 0x52, 0xf9, 0x70, 0xac, 0x0c } },
                { 55, new byte[] { 0xd1, 0xfc, 0x52, 0xf9, 0x70, 0xac, 0x2c } },
                { 64, new byte[] { 0xe7, 0xfd, 0x52, 0xf9, 0x70, 0xac, 0x2c, 0x9b } },
            };


            foreach (var knownValue in knownValues)
            {
                Assert.Equal(
                    knownValue.Value, 
                    hashFunction.ComputeHash(
                        TestConstants.FooBar, 
                        knownValue.Key));
            }
        }