function monoalphabetic_test ( )

%*****************************************************************************80
%
%% monoalphabetic_test() tests monoalphabetic().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 February 2019
%
%  Author:
%
%    John Burkardt
%
  addpath ( '../monoalphabetic' );

  timestamp ( );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'monoalphabetic_test():\n' );
  fprintf ( 1, '  MATLAB/Octave version %s\n', version ( ) );
  fprintf ( 1, '  Test monoalphabetic()\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  MONO_ENCRYPT encrypts a plain text using a monoalphabetic\n' );
  fprintf ( 1, '  substitution cipher.\n' );
  fprintf ( 1, '  MONO_DECRYPT decrypts an encryted text.\n' );
%
%  Typewriter code.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Here we use a "typewriter code" to encrypt the message.\n' );
  fprintf ( 1, '\n' );

  abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  code ='QWERTYUIOPASDFGHJKLZXCVBNM';
  plain = 'A man, a plan, a canal - Panama!';
  crypt = mono_encrypt ( code, plain );
  decrypt = mono_decrypt ( code, crypt );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ABC:  "%s"\n', abc );
  fprintf ( 1, 'CODE: "%s"\n', code );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'PLAIN:   "%s"\n', plain );
  fprintf ( 1, 'CRYPT:   "%s"\n', crypt );
  fprintf ( 1, 'DECRYPT: "%s"\n', decrypt );
%
%  All symbol code.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  We can use symbols in the code, but if the plaintext\n' );
  fprintf ( 1, '  and code both use punctuation, we will have some mistakes.\n' );
  fprintf ( 1, '\n' );

  abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  code ='~`!@#$%^&*()-_=+[{]};:,<.>';
  plain = 'A man, a plan, a canal - Panama!';
  crypt = mono_encrypt ( code, plain );
  decrypt = mono_decrypt ( code, crypt );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ABC:  "%s"\n', abc );
  fprintf ( 1, 'CODE: "%s"\n', code );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'PLAIN:   "%s"\n', plain );
  fprintf ( 1, 'CRYPT:   "%s"\n', crypt );
  fprintf ( 1, 'DECRYPT: "%s"\n', decrypt );
%
%  Symmetric (backwards alphabet) code.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  If we use a "symmetric" code, then encrypting twice\n' );
  fprintf ( 1, '  actually decodes the message.\n' );
  fprintf ( 1, '\n' );

  abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  code ='ZYXWVUTSRQPONMLKJIHGFEDCBA';
  plain = 'A man, a plan, a canal - Panama!';
  crypt = mono_encrypt ( code, plain );
  crypt2 = mono_encrypt ( code, crypt );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ABC:  "%s"\n', abc );
  fprintf ( 1, 'CODE: "%s"\n', code );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'PLAIN:  "%s"\n', plain );
  fprintf ( 1, 'CRYPT:  "%s"\n', crypt );
  fprintf ( 1, 'CRYPT2: "%s"\n', crypt2 );
%
%  Symmetric (backwards alphabet) code.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, '  Another ATBASH example.\n' );
  fprintf ( 1, '\n' );

  abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  code ='ZYXWVUTSRQPONMLKJIHGFEDCBA';
  plain = 'There are a thousand hacking at the branches of evil for every one who is striking at its root.';
  crypt = mono_encrypt ( code, plain );
  crypt2 = mono_encrypt ( code, crypt );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'ABC:  "%s"\n', abc );
  fprintf ( 1, 'CODE: "%s"\n', code );
  fprintf ( 1, '\n' );
  fprintf ( 1, 'PLAIN:  "%s"\n', plain );
  fprintf ( 1, 'CRYPT:  "%s"\n', crypt );
  fprintf ( 1, 'CRYPT2: "%s"\n', crypt2 );
%
%  Terminate.
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'monoalphabetic_test(:\n' );
  fprintf ( 1, '  Normal end of execution.\n' );
  fprintf ( 1, '\n' );
  timestamp ( );

  rmpath ( '../monoalphabetic' );

  return
end
function timestamp ( )

%*****************************************************************************80
%
%% timestamp() prints the current YMDHMS date as a timestamp.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    14 February 2003
%
%  Author:
%
%    John Burkardt
%
  t = now;
  c = datevec ( t );
  s = datestr ( c, 0 );
  fprintf ( 1, '%s\n', s );

  return
end

