#include "crypto.h"
#include <QTextStream>
#include <argumentlist.h>
#include <qstd.h>

using namespace qstd;

void usage(const QString& appname) {
  cout << " Usage:\n"
		 << appname 
		 << " actionSwitch "
		 << " -k keyValue "
		 << " -s string\n"
		 << "where\nactionswitch is either -e (encrypt) or -d (decrypt)\n"
		 << "(default is encrypt)."
		 << "keyvalue is the encryption key if you don't use default key.\n"	 
		 << "string is the string to be encrypted or decrypted.\n"
		 << "Converted string is sent to stdout."
		 << endl;
}

int main(int argc, char** argv)  {

     QString str1 ("asdfghjkl;QWERTYUIOP{}}|123456&*()_+zxcvnm,,, ./?"), 
             str2;
     cout << "Original string: " << str1 << endl;
     QString seqstr("pspsp");
     ushort key(12579);
     Crypto crypt(key, seqstr);
     str2 = crypt.encrypt(str1);
     cout << "Encrypted string: " << str2 << endl;
     cout << "Recovered string: " << crypt.decrypt(str2) << endl;

	  /*
  ArgumentList al(argc, argv);
  QString appname(al.takeFirst());
  QString str1(al.getSwitchArg("-s"));
  if(str1 == QString()) {
	 usage(appname);
	 exit(1);
  }
  bool decrypt(al.getSwitch("-d")); 
  QString keystr(al.getSwitchArg("-k"));
  unsigned key(214365);   // default
  if(keystr != QString())
	 key = keystr.toUInt();
  QString seqstr("pspsp");
  Crypto crypt(key, seqstr);

  if(decrypt)
	 cout << crypt.decrypt(str1);
  else
	 cout << crypt.encrypt(str1);
	  */
}


