Blake2Sharp.Blake2BCore.HashCore C# (CSharp) Method

HashCore() public method

public HashCore ( byte array, int start, int count ) : void
array byte
start int
count int
return void
        public void HashCore(byte[] array, int start, int count)
        {
            if (!_isInitialized)
                throw new InvalidOperationException("Not initialized");
            if (array == null)
                throw new ArgumentNullException("array");
            if (start < 0)
                throw new ArgumentOutOfRangeException("start");
            if (count < 0)
                throw new ArgumentOutOfRangeException("count");
            if ((long)start + (long)count > array.Length)
                throw new ArgumentOutOfRangeException("start+count");
            int offset = start;
            int bufferRemaining = BlockSizeInBytes - _bufferFilled;

            if ((_bufferFilled > 0) && (count > bufferRemaining))
            {
                Array.Copy(array, offset, _buf, _bufferFilled, bufferRemaining);
                _counter0 += BlockSizeInBytes;
                if (_counter0 == 0)
                    _counter1++;
                Compress(_buf, 0);
                offset += bufferRemaining;
                count -= bufferRemaining;
                _bufferFilled = 0;
            }

            while (count > BlockSizeInBytes)
            {
                _counter0 += BlockSizeInBytes;
                if (_counter0 == 0)
                    _counter1++;
                Compress(array, offset);
                offset += BlockSizeInBytes;
                count -= BlockSizeInBytes;
            }

            if (count > 0)
            {
                Array.Copy(array, offset, _buf, _bufferFilled, count);
                _bufferFilled += count;
            }
        }

Usage Example

Beispiel #1
0
 public override void Init()
 {
     core.Initialize(rawConfig);
     if (key != null)
     {
         core.HashCore(key, 0, key.Length);
     }
 }