// ------------------------------- //
// -------- Start of File -------- //
// ------------------------------- //
// ----------------------------------------------------------- // 
// C++ Source Code File Name: edscfg.cpp 
// C++ Compiler Used: MSVC, BCC32, GCC, HPUX aCC, SOLARIS CC
// Produced By: glNET Software
// File Creation Date: 10/15/1999 
// Date Last Modified: 05/25/2001
// Copyright (c) 2001 glNET Software
// ----------------------------------------------------------- // 
// ------------- Program Description and Details ------------- // 
// ----------------------------------------------------------- // 
/*
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
 
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  
USA

Code used to test encrypted data sets.
*/
// ----------------------------------------------------------- // 
#include <iostream.h>
#include <iomanip.h>
#include <string.h>
#include "eds101.h"

#ifdef __MSVC_DEBUG__
#include "leaktest.h"
#endif

void PrintEDSTable()
{
  edsString eds;
  for(unsigned i = 0; i < edsTableSize; i++) 
  cout << setfill('0') << setw(4) << hex << eds.eds_table[i] << ' ';
  cout << endl;
}

void EncryptString(const char *s)
{
  char *s1 = (char *)s;
  unsigned len = strlen(s1);
  unsigned i = 0;
  edsString eds;
  
  edsWORD eds_string[edsMaxLine];
  
  for(i = 0; i < len; i++) {
    eds_string[i] = eds.EncryptString((unsigned char)*s1++);
    cout << setfill('0') << setw(4) << hex << eds_string[i] << ' ';
  }
  cout << endl;

  for(i = 0; i < len; i++) {
    unsigned char c;
    if(eds.DecryptString(eds_string[i], c))
      cout << c;
  }
  cout << endl;
}

void PrintStaticTable()
{
  edsPrintStaticEncryptionTable(cout);
  edsTestStaticEncryptionTable(cout);
}

int main()
{
#ifdef __MSVC_DEBUG__
  InitLeakTest();
#endif

  const char *s1 = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789\n";
  const char *s2 = "the quick brown fox jumps over the lazy dog 0123456789\n";
  const char *s3 = "!@#$%^&*()-_=+[{]}\\|;:\'\",<.>/?`~\n";
  const char *s4 = "\t\n\r\b";
  
  cout << endl;
  cout << "Encrypting/Decrypting string number 1..." << endl;
  EncryptString(s1);
  
  cout << "Encrypting/Decrypting string number 2..." << endl;
  EncryptString(s2);
  
  cout << "Encrypting/Decrypting string number 3..." << endl;
  EncryptString(s3);
    
  cout << "Encrypting/Decrypting string number 4..." << endl;
  EncryptString(s4);

  return 0;
}
// ----------------------------------------------------------- //
// ------------------------------- //
// --------- End of File --------- //
// ------------------------------- //