예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="shift"></param>
        public Dice(Shift shift)
        {
            _shift = shift;
            var height = shift.Height.ToString();

            height = height.PadLeft(height.Length + height.Length % 2, '0');
            _seed1 = HexHashUtil.HashSha256(shift.AdHex + height);
            _seed2 = HexHashUtil.HashSha256(shift.AdHex + shift.BkHex).Substring(1);
            _seed3 = HexHashUtil.HashSha256(height + shift.BkHex).Substring(3);
        }
예제 #2
0
        public Dice(Shift shift, int modifier)
        {
            _shift = shift;

            var height = shift.Height.ToString();

            height = height.PadLeft(height.Length + height.Length % 2, 'a');

            var modifierStr = modifier.ToString();

            modifierStr = modifierStr.PadLeft(modifierStr.Length + modifierStr.Length % 2, 'a');

            _seed1 = HexHashUtil.HashSha256(HexHashUtil.HashSha256(modifierStr) + height);
            _seed2 = HexHashUtil.HashSha256(modifierStr + height).Substring(1);
            _seed3 = HexHashUtil.HashSha256(height + modifierStr + shift.BkHex).Substring(3);
        }
예제 #3
0
        public void HashSha256Test()
        {
            var shift = new Shift(0,
                                  1530914381,
                                  "32ad9e02792599dfdb6a9d0bc0b924da23bd96b1b7eb4f0a68",
                                  7234,
                                  "00000000090d6c6b058227bb61ca2915a84998703d4444cc2641e6a0da4ba37e",
                                  2,
                                  "163d2e383c77765232be1d9ed5e06749a814de49b4c0a8aebf324c0e9e2fd1cf",
                                  1.00m,
                                  0.0001m);

            var bytes       = HexHashUtil.StringToByteArray(shift.AdHex);
            var hashedBytes = HexHashUtil.HashSha256(bytes);
            var hash        = HexHashUtil.ByteArrayToString(hashedBytes);

            Assert.Equal("bcd35d9f6de167fada34bfeb0c59d2b1a55974b9460c54f42dfff2e86cf8c58b", hash);
        }