function [x] = pp(a,p) % Pretty print.

% Groups a string of hexadecimal digits into groups of p characters,
% insterting a space between each p characters.
% 
% Copyright (c) 2008 Karl J A Petre and Xavier J Ortiz.
% This file was last updated 7 December 2008.
% 
% This code is included with the Matlab Whirlpool package.
% 
% The Whirlpool algorithm was developed by:
%     Paulo S. L. M. Barreto (pbarreto@scopus.com.br)
%     Vincent Rijmen (vincent.rijmen@cryptomathic.com)
% 
% This software is provided by the author as is and any express
% or implied warranties, including, but not limited to, the implied 
% warranties of merchantability and fitness for a particular purpose
% are disclaimed. In no event shall the author or contributors be
% liable for any direct, indirect, incidental, special, exemplary, or
% consequential damages (including, but not limited to, procurement of
% substitute goods or services; loss of use, data, or profits; or 
% business interruption) however caused and on any theory of liability,
% whether in contract, strict liability, or tort (including negligence
% or otherwise) arising in any way out of the use of this software,
% even if advised on the possibility of such damage.

if nargin < 2; p = 2; end % Assume byte blocks.

b = bv2hex(a);
i = 1;
x = [];
while i < length(b)
    x = [x ' ' b(i:i+1)];
    i = i+2;
end
x = x(2:end);