///////////////////////////////////////////////////////////////////////
/// SharpHash Library
/// Copyright(c) 2021 Mbadiwe Nnaemeka Ronald
/// Github Repository <https://github.com/ron4fun/HashLibPlus>
///
/// The contents of this file are subject to the
/// Mozilla Public License Version 2.0 (the "License");
/// you may not use this file except in
/// compliance with the License. You may obtain a copy of the License
/// at https://www.mozilla.org/en-US/MPL/2.0/
///
/// Software distributed under the License is distributed on an "AS IS"
/// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
/// the License for the specific language governing rights and
/// limitations under the License.
///
/// Acknowledgements:
///
/// Thanks to Ugochukwu Mmaduekwe (https://github.com/Xor-el) for his creative
/// development of this library in Pascal/Delphi (https://github.com/Xor-el/HashLib4Pascal).
///
////////////////////////////////////////////////////////////////////////

#pragma once

#include "../Base/MultipleTransformNonBlock.h"


class DEK : public MultipleTransformNonBlock, public virtual IIHash32, 
	public virtual IITransformBlock
{
public:
	DEK()
		: MultipleTransformNonBlock(4, 1)
	{
		_name = __func__;
	} // end constructor

	virtual IHash Clone() const
	{
		DEK HashInstance = DEK();

		HashInstance._buffer = _buffer;

		HashInstance.SetBufferSize(GetBufferSize());

		return std::make_shared<DEK>(HashInstance);
	}

protected:
	virtual IHashResult ComputeAggregatedBytes(const HashLibByteArray& a_data)
	{
		UInt32 _hash = UInt32(a_data.size());

		for (UInt32 i = 0; i < a_data.size(); i++)
			_hash = Bits::rotateLeft32(_hash, 5) ^ a_data[i];

		return std::make_shared<HashResult>(_hash);
	} // end function ComputeAggregatedBytes

}; // end class DEK
