Пример #1
0
        public void Digest(ReadOnlySpan <byte> data, Span <byte> result, params object[] extra)
        {
            Contract.Requires <ArgumentException>(result.Length >= 32, $"{nameof(result)} must be greater or equal 32 bytes");

            // get nFactor
            var ts      = ((DateTimeOffset)clock.Now).ToUnixTimeSeconds();
            var n       = timetable.First(x => ts >= x.Item2).Item1;
            var nFactor = Math.Log(n) / Math.Log(2);

            fixed(byte *input = data)
            {
                fixed(byte *output = result)
                {
                    LibMultihash.scryptn(input, output, (uint)nFactor, (uint)data.Length);
                }
            }
        }
Пример #2
0
        public byte[] Digest(byte[] data, params object[] extra)
        {
            Assertion.RequiresNonNull(data, nameof(data));

            var ts      = ((DateTimeOffset)clock.Now).ToUnixTimeSeconds();
            var n       = timetable.First(x => ts >= x.Item2).Item1;
            var nFactor = Math.Log(n) / Math.Log(2);

            var result = new byte[32];

            fixed(byte *input = data)
            {
                fixed(byte *output = result)
                {
                    LibMultihash.scryptn(input, output, (uint)nFactor, (uint)data.Length);
                }
            }

            return(result);
        }