%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Copyright: 2010 Integrated Sytems Laboratory, ETH Zurich
%% http://www.iis.ee.ethz.ch/~sha3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Hs = finalization(V, H, S, p)
Hs = zeros(1, p.h/p.w);
for j=1:8,
Hs(j) = bitxor(bitxor(bitxor(H(j), V(j)), V(j+8)), S(mod(j-1,4)+1));
end