private int GenerateInternal(byte b, byte[] salt, ref bool isSaltEncrypted, bool doNotEncrypt = false) { var byteBuffer = new byte[salt.Length + 1]; try { //Decrypt salt if (isSaltEncrypted) { _memoryProtector.Unprotect(salt); isSaltEncrypted = false; } //Append salt + byte Array.Copy(salt, byteBuffer, salt.Length); byteBuffer[salt.Length] = b; //Hash it var result = _fastHasher.ComputeFast(byteBuffer); return(result); } finally { Array.Clear(byteBuffer, 0, byteBuffer.Length); //Encrypt the salt if (!isSaltEncrypted && !doNotEncrypt) { _memoryProtector.Protect(salt); isSaltEncrypted = true; } } }
private int Generate(byte b, byte[] salt) { byte[] byteBuffer = null; try { byteBuffer = salt.CopyToNewArray(); byteBuffer[salt.Length - 1] = b; var result = _fastHasher.ComputeFast(byteBuffer); return(result); } finally { if (byteBuffer != null) { Array.Clear(byteBuffer, 0, byteBuffer.Length); } } }
protected int Hash(byte[] input) => _fastHasher.ComputeFast(input);