# (C++) TestEncranger

Encranger, short for 'ENCryption by RAndom Number GeneratoR' is a tool to encrypt en de-encrypt single-line text messages. MultiEncranger is the multi-line version of Encranger.

## TestEncranger encryption algorithm

The Encranger encryption algorithm is a form of the Vigenere cipher. In the Vigenere cipher the shift of letters differs per position and are determined by the letters in a keyword. In the Encranger algorithm these shifts are determined by a random number generator, set by a key.

To make this clear, I will first briefly explain Caesar cipher, then I ll explain Vigenere cipher and finally show the difference between the Vigenere cipher and the Encranger algorithm.

Caesar cipher encrypts text by adding a value to each letter in a word. This value is the key or password. For example, the text AAAAA with the key +1 becomes BBBBB .

Vigenere cipher encrypts text by adding a value to each letter in a word, in which the shift changes per letter. For example, the key ABCDE might hold the shifts +1 +2 +3 +4 +5 . The plaintext AAAAA encrypted by the key ABCDE then becomes BCDEF .

Encranger, as Vigenere cipher, encrypts text by adding a value to each letter in a word, in which the shift changes per letter. These shifts are not determined by a word, but are generated randomly using a value (the key). For example, using an alphabet of only five letters, the value of 123 generates a shift sequence of +5 +3 +1 +2 +4. The plaintext AAAAA encrypted by the value 123 then becomes ADBCE. Encranger uses n (about fifty) characters, consisting of letters and punctuation characters. For a certain Encranger key, it is theoretically possible to calculate the Vigenere cipher key (also of n characters). Because Encranger uses the C++ random number generator to generate a random sequence of letter shifts, it is estimated that Encranger only has 32768 (RAND_MAX) or 4294967296 (2^32, the maximal integer value) different keys, instead of the highest possible, which would be the factorial of n.

## Technical facts

Application type(s)

Operating system(s) or programming environment(s)

Libraries used:

• Boost: version 1.49
• Qt: version 5.1.1 (32 bit)
• STL: GNU ISO C++ Library, version 4.7.3
• Wt: version 3.2.2

## Qt project file: ToolTestEncrangerDesktop.pro

 ``` QT       += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra TEMPLATE = app INCLUDEPATH += \     ../../Classes/CppAbout \     ../../Classes/CppEncranger \     ../../Classes/CppLoopReader \     ../../Classes/CppQtAboutDialog SOURCES += qtmain.cpp \     qttestencrangerdialog.cpp \     testencrangerdialog.cpp \     ../../Classes/CppAbout/about.cpp \     ../../Classes/CppEncranger/encranger.cpp \     ../../Classes/CppQtAboutDialog/qtaboutdialog.cpp HEADERS  += \     qttestencrangerdialog.h \     testencrangerdialog.h \     ../../Classes/CppAbout/about.h \     ../../Classes/CppEncranger/encranger.h \     ../../Classes/CppLoopReader/loopreader.h \     ../../Classes/CppQtAboutDialog/qtaboutdialog.h FORMS    += \     qttestencrangerdialog.ui \     ../../Classes/CppQtAboutDialog/qtaboutdialog.ui RESOURCES += \     ToolTestEncranger.qrc ```

## Qt project file: ToolTestEncrangerWebsite.pro

 ``` #------------------------------------------------- # # Project created by QtCreator 2011-03-06T10:58:35 # #------------------------------------------------- QT       += core QT       -= gui LIBS += -lwt -lwthttp -lboost_program_options CONFIG   += console CONFIG   -= app_bundle TEMPLATE = app INCLUDEPATH += \     ../../Classes/CppAbout \     ../../Classes/CppEncranger \     ../../Classes/CppLoopReader \     ../../Classes/CppWtAboutDialog \     ../../Classes/CppWtAutoConfig SOURCES += wtmain.cpp \     testencrangerdialog.cpp \     ../../Classes/CppAbout/about.cpp \     ../../Classes/CppEncranger/encranger.cpp \     ../../Classes/CppWtAboutDialog/wtaboutdialog.cpp \     wttestencrangermaindialog.cpp \     wttestencrangermenudialog.cpp \     ../../Classes/CppWtAutoConfig/wtautoconfig.cpp HEADERS  += \     testencrangerdialog.h \     ../../Classes/CppAbout/about.h \     ../../Classes/CppEncranger/encranger.h \     ../../Classes/CppLoopReader/loopreader.h \     ../../Classes/CppWtAboutDialog/wtaboutdialog.h \     wttestencrangermaindialog.h \     wttestencrangermenudialog.h \     ../../Classes/CppWtAutoConfig/wtautoconfig.h RESOURCES += \     ToolTestEncranger.qrc ```

## qtmain.cpp

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #include #include "qttestencrangerdialog.h" //--------------------------------------------------------------------------- int .htm">main(int argc, char *argv[]) {   QApplication a(argc, argv);   QtTestEncrangerDialog w;   w.show();   return a.exec(); } //--------------------------------------------------------------------------- ```

## qttestencrangerdialog.h

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #ifndef QTTESTENCRANGERDIALOG_H #define QTTESTENCRANGERDIALOG_H #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #include #pragma GCC diagnostic pop namespace Ui {   class QtTestEncrangerDialog; } namespace ribi { struct TestEncrangerDialog; class QtTestEncrangerDialog : public QDialog {   Q_OBJECT public:   explicit QtTestEncrangerDialog(QWidget *parent = 0);   QtTestEncrangerDialog(const QtTestEncrangerDialog&) = delete;   QtTestEncrangerDialog& operator=(const QtTestEncrangerDialog&) = delete;   ~QtTestEncrangerDialog(); protected: private:   Ui::QtTestEncrangerDialog *ui;   static const std::string GetVersion();   static const std::vector GetVersionHistory();   TestEncrangerDialog * const m_dialog; private slots:   void on_button_about_clicked();   void on_button_deencrypt_clicked();   void on_button_encrypt_clicked(); }; } //~namespace ribi #endif // QTTESTENCRANGERDIALOG_H ```

## qttestencrangerdialog.cpp

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #include "qttestencrangerdialog.h" #include #include #include "encranger.h" #include "loopreader.h" #include "qtaboutdialog.h" #include "ui_qttestencrangerdialog.h" #include "testencrangerdialog.h" #pragma GCC diagnostic pop ribi::QtTestEncrangerDialog::QtTestEncrangerDialog(QWidget *parent) :     QDialog(parent),     ui(new Ui::QtTestEncrangerDialog),     m_dialog(new TestEncrangerDialog) {   ui->setupUi(this); } ribi::QtTestEncrangerDialog::~QtTestEncrangerDialog() {   delete ui;   delete m_dialog; } void ribi::QtTestEncrangerDialog::on_button_encrypt_clicked() {   try   {     boost::lexical_cast(ui->edit_key->text().toStdString());   }   catch (boost::bad_lexical_cast&)   {     ui->edit_encrypted_text->setText("ERROR: Key must be a positive number");     return;   }   const int key = boost::lexical_cast(ui->edit_key->text().toStdString());   if (key < 0)   {     ui->edit_encrypted_text->setText("ERROR: Key must be a positive number");     return;   }   m_dialog->SetPlainText(ui->edit_plaintext->text().toStdString());   m_dialog->SetKey(key);   m_dialog->Encrypt();   ui->edit_encrypted_text->setText(m_dialog->GetEncryptedText().c_str()); } void ribi::QtTestEncrangerDialog::on_button_deencrypt_clicked() {   try   {     boost::lexical_cast(ui->edit_key->text().toStdString());   }   catch (boost::bad_lexical_cast&)   {     ui->edit_encrypted_text->setText("ERROR: Key must be a positive number");     return;   }   const int key = boost::lexical_cast(ui->edit_key->text().toStdString());   if (key < 0)   {     ui->edit_encrypted_text->setText("ERROR: Key must be a positive number");     return;   }   m_dialog->SetEncryptedText(ui->edit_encrypted_text->text().toStdString());   m_dialog->SetKey(key);   m_dialog->Deencrypt();   ui->edit_plaintext->setText(m_dialog->GetPlainText().c_str()); } void ribi::QtTestEncrangerDialog::on_button_about_clicked() {   About a = TestEncrangerDialog::GetAbout();   QtAboutDialog d(a);   d.exec(); } ```

## testencrangerdialog.h

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #ifndef TESTENCRANGERDIALOG_H #define TESTENCRANGERDIALOG_H #include #include #include #include "about.h" #include "encranger.h" namespace ribi { struct TestEncrangerDialog {   TestEncrangerDialog();   void Deencrypt();   void Encrypt();   const std::string& GetEncryptedText() const { return m_encrypted_text; }   int GetKey() const { return m_key; }   const std::string& GetPlainText() const { return m_plain_text; }   void SetEncryptedText(const std::string& s);   void SetKey(const int i);   void SetPlainText(const std::string& s);   static const About GetAbout();   static const std::string GetVersion();   static const std::vector GetVersionHistory();   private:   boost::scoped_ptr m_encranger;   std::string m_encrypted_text;   int m_key;   std::string m_plain_text; }; } //~namespace ribi #endif // TESTENCRANGERDIALOG_H ```

## testencrangerdialog.cpp

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #include "testencrangerdialog.h" #include "loopreader.h" ribi::TestEncrangerDialog::TestEncrangerDialog()   : m_encranger(new Encranger(0)), // 0 == m_key     m_encrypted_text{},     m_key(0),     m_plain_text{} { } void ribi::TestEncrangerDialog::Deencrypt() {   m_plain_text = m_encranger->Deencrypt(m_encrypted_text); } void ribi::TestEncrangerDialog::Encrypt() {   m_encrypted_text = m_encranger->Encrypt(m_plain_text); } void ribi::TestEncrangerDialog::SetEncryptedText(const std::string& s) {   m_encrypted_text = s; } void ribi::TestEncrangerDialog::SetKey(const int i) {   m_encranger.reset(new Encranger(i)); } void ribi::TestEncrangerDialog::SetPlainText(const std::string& s) {   m_plain_text = s; } const ribi::About ribi::TestEncrangerDialog::GetAbout() {   About a(     "Richel Bilderbeek",     "TestEncranger",     "tool to test the Encranger class",     "the 31st of August 2011",     "2009-2011",     "http://www.richelbilderbeek.nl/ToolTestEncranger.html",     GetVersion(),     GetVersionHistory());   a.AddLibrary("Encranger version: " + Encranger::GetVersion());   a.AddLibrary("LoopReader version: " + LoopReader::GetVersion());   return a; } const std::string ribi::TestEncrangerDialog::GetVersion() {   return "2.4"; } const std::vector ribi::TestEncrangerDialog::GetVersionHistory() {   return {     "2009-08-22: Version 1.0: initial version (then called 'Encranger') programmed in C++ Builder",     "2011-03-06: Version 2.0: port to Qt Creator, renamed application to TestEncranger",     "2011-03-22: Version 2.1: seperated GUI from logic, added website version",     "2011-04-25: Version 2.2: removed website version\'s Close button",     "2011-06-22: Version 2.3: improved website version",     "2011-08-31: Version 2.4: added arrows and Welcome image"   }; } ```

## wtmain.cpp

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #include #include //--------------------------------------------------------------------------- #include "wtautoconfig.h" #include "wttestencrangermenudialog.h" //--------------------------------------------------------------------------- struct WtApplication : public Wt::WApplication {   WtApplication(const Wt::WEnvironment& env)     : Wt::WApplication(env),     m_dialog(new WtTestEncrangerMenuDialog)   {     this->setTitle("TestEncranger");     this->useStyleSheet("wt.css");     root()->addWidget(m_dialog);   }   private:   WtTestEncrangerMenuDialog * const m_dialog; }; //--------------------------------------------------------------------------- Wt::WApplication *createApplication(   const Wt::WEnvironment& env) {   return new WtApplication(env); } //--------------------------------------------------------------------------- int .htm">main(int argc, char **argv) {   WtAutoConfig::SaveDefaultStylesheet();   WtAutoConfig a(argc,argv,createApplication);   return a.Run(); } //--------------------------------------------------------------------------- ```

## wttestencrangermaindialog.h

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #ifndef WTTESTENCRANGERDIALOG_H #define WTTESTENCRANGERDIALOG_H //--------------------------------------------------------------------------- #include #include #include //--------------------------------------------------------------------------- namespace ribi { struct TestEncrangerDialog; //--------------------------------------------------------------------------- struct WtTestEncrangerMainDialog : public Wt::WContainerWidget {   WtTestEncrangerMainDialog();   WtTestEncrangerMainDialog(const WtTestEncrangerMainDialog&) = delete;   WtTestEncrangerMainDialog& operator=(const WtTestEncrangerMainDialog&) = delete;   private:   boost::scoped_ptr m_dialog;   Wt::WLineEdit * m_edit_encrypted_text;   Wt::WLineEdit * m_edit_key;   Wt::WLineEdit * m_edit_plain_text;   void OnDeencryptClick();   void OnEncryptClick();   void ShowMain(); }; } //~namespace ribi #endif // WTTESTENCRANGERDIALOG_H ```

## wttestencrangermaindialog.cpp

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #include //--------------------------------------------------------------------------- #include #include #include #include #include //--------------------------------------------------------------------------- #include "testencrangerdialog.h" #include "wttestencrangermaindialog.h" //--------------------------------------------------------------------------- ribi::WtTestEncrangerMainDialog::WtTestEncrangerMainDialog()   : m_dialog(new TestEncrangerDialog),     m_edit_encrypted_text(0),     m_edit_key(0),     m_edit_plain_text(0) {   this->setContentAlignment(Wt::AlignCenter);   ShowMain(); } //--------------------------------------------------------------------------- void ribi::WtTestEncrangerMainDialog::OnDeencryptClick() {   m_dialog->SetEncryptedText(m_edit_encrypted_text->text().toUTF8());   try   {     boost::lexical_cast(this->m_edit_key->text().toUTF8());   }   catch(boost::bad_lexical_cast&)   {     return;   }   m_dialog->SetKey(boost::lexical_cast(m_edit_key->text().toUTF8()));   m_dialog->Deencrypt();   m_edit_plain_text->setText(m_dialog->GetPlainText().c_str()); } //--------------------------------------------------------------------------- void ribi::WtTestEncrangerMainDialog::OnEncryptClick() {   m_dialog->SetPlainText(m_edit_plain_text->text().toUTF8());   try   {     boost::lexical_cast(this->m_edit_key->text().toUTF8());   }   catch(boost::bad_lexical_cast&)   {     return;   }   m_dialog->SetKey(boost::lexical_cast(m_edit_key->text().toUTF8()));   m_dialog->Encrypt();   m_edit_encrypted_text->setText(m_dialog->GetEncryptedText().c_str()); } //--------------------------------------------------------------------------- void ribi::WtTestEncrangerMainDialog::ShowMain() {   this->clear();   this->addWidget(new Wt::WBreak);   this->addWidget(new Wt::WBreak);   //Plain text   {     m_edit_plain_text = new Wt::WLineEdit("This is plaintext");     m_edit_plain_text->setMinimumSize(400,Wt::Vertical);     this->addWidget(m_edit_plain_text);   }   this->addWidget(new Wt::WBreak);   this->addWidget(new Wt::WBreak);   //Arrow down   this->addWidget(new Wt::WImage("ToolTestEncrangerArrowDown16x16.png"));   //Encrypt button   {     Wt::WPushButton * const button = new Wt::WPushButton("Encrypt");     button->clicked().connect(       this, &ribi::WtTestEncrangerMainDialog::OnEncryptClick);     this->addWidget(button);   }   //Arrow down   this->addWidget(new Wt::WImage("ToolTestEncrangerArrowDown16x16.png"));   this->addWidget(new Wt::WLabel("Key: "));   {     m_edit_key = new Wt::WLineEdit("12345");     this->addWidget(m_edit_key);   }   //Arrow up   this->addWidget(new Wt::WImage("ToolTestEncrangerArrowUp16x16.png"));   //Deencrypt button   {     Wt::WPushButton * const button = new Wt::WPushButton("Deencrypt");     button->clicked().connect(       this, &ribi::WtTestEncrangerMainDialog::OnDeencryptClick);     this->addWidget(button);   }   //Arrow up   this->addWidget(new Wt::WImage("ToolTestEncrangerArrowUp16x16.png"));   this->addWidget(new Wt::WBreak);   this->addWidget(new Wt::WBreak);   //Encrypted text   {     m_edit_encrypted_text = new Wt::WLineEdit;     m_edit_encrypted_text->setMinimumSize(400,Wt::Vertical);     this->addWidget(m_edit_encrypted_text);   }   OnEncryptClick(); } //--------------------------------------------------------------------------- ```

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #ifndef WTTESTENCRANGERMENUDIALOG_H #define WTTESTENCRANGERMENUDIALOG_H //--------------------------------------------------------------------------- #include //--------------------------------------------------------------------------- namespace ribi { struct WtTestEncrangerMenuDialog : public Wt::WContainerWidget {   WtTestEncrangerMenuDialog();   private:   Wt::WWidget * CreateNewAboutDialog() const;   Wt::WWidget * CreateNewMainDialog() const;   Wt::WWidget * CreateNewWelcomeDialog() const; }; } //~namespace ribi #endif // WTTESTENCRANGERMENUDIALOG_H ```

 ``` //--------------------------------------------------------------------------- /* TestEncranger, tool to test the Encranger class Copyright (C) 2009-2011 Richel Bilderbeek This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ //--------------------------------------------------------------------------- //From http://www.richelbilderbeek.nl/ToolTestEncranger.html //--------------------------------------------------------------------------- #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Weffc++" #include //--------------------------------------------------------------------------- #include #include //--------------------------------------------------------------------------- #include #include #include #include #include #include #include #include //--------------------------------------------------------------------------- #include "about.h" #include "testencrangerdialog.h" #include "wtautoconfig.h" #include "wtaboutdialog.h" #include "wttestencrangermaindialog.h" #include "wttestencrangermenudialog.h" //--------------------------------------------------------------------------- #include #pragma GCC diagnostic pop ribi::WtTestEncrangerMenuDialog::WtTestEncrangerMenuDialog() {   //Create resources   {     std::vector image_names;     image_names.push_back("ToolTestEncrangerArrowDown16x16.png");     image_names.push_back("ToolTestEncrangerArrowDown34x34.png");     image_names.push_back("ToolTestEncrangerArrowUp16x16.png");     image_names.push_back("ToolTestEncrangerArrowUp34x34.png");     image_names.push_back("ToolTestEncrangerWelcome.png");     BOOST_FOREACH(const std::string& filename,image_names)     {       if (!(QFile::exists(filename.c_str())))       {         QFile f( (std::string(":/images/") + filename).c_str() );         f.copy(filename.c_str());       }       if (!boost::filesystem::exists(filename.c_str()))       {         std::cerr << "File not found: " << filename << '\n';       }       assert(boost::filesystem::exists(filename.c_str()));     }   }   this->setContentAlignment(Wt::AlignCenter);   {     Wt::WLabel * const title = new Wt::WLabel("TestEncranger");     title->setStyleClass("title");     this->addWidget(title);   }   //Menu   {     Wt::WStackedWidget * const contents = new Wt::WStackedWidget;     Wt::WMenu * const menu = new Wt::WMenu(contents,Wt::Horizontal);     //Using CSS styleclass is the best (only?) way to display the menu well     menu->setStyleClass("menu");     {       Wt::WMenuItem * const item = new Wt::WMenuItem(         "Welcome",         CreateNewWelcomeDialog());       menu->addItem(item);     }     {       Wt::WMenuItem * const item = new Wt::WMenuItem(         "Start",         CreateNewMainDialog());       menu->addItem(item);     }     {       Wt::WMenuItem * const item = new Wt::WMenuItem(         "About",         CreateNewAboutDialog());       menu->addItem(item);     }     //Display menu on top     this->addWidget(menu);     this->addWidget(new Wt::WBreak);     //Display contents below menu     this->addWidget(contents);   } } //--------------------------------------------------------------------------- Wt::WWidget * ribi::WtTestEncrangerMenuDialog::CreateNewAboutDialog() const {   About a = TestEncrangerDialog::GetAbout();   a.AddLibrary("WtAutoConfig version: " + WtAutoConfig::GetVersion());   WtAboutDialog * const d = new WtAboutDialog(a,false);   assert(d);   return d; } //--------------------------------------------------------------------------- Wt::WWidget * ribi::WtTestEncrangerMenuDialog::CreateNewMainDialog() const {   WtTestEncrangerMainDialog * const d = new WtTestEncrangerMainDialog;   assert(d);   return d; } //--------------------------------------------------------------------------- Wt::WWidget * ribi::WtTestEncrangerMenuDialog::CreateNewWelcomeDialog() const {   Wt::WContainerWidget * dialog = new Wt::WContainerWidget;   dialog->setContentAlignment(Wt::AlignCenter);   dialog->addWidget(new Wt::WBreak);   new Wt::WLabel("Welcome to TestEncranger",dialog);   new Wt::WBreak(dialog);   new Wt::WBreak(dialog);   new Wt::WLabel("TestEncranger demonstrates the Encranger encryption and de-encryption algorithm",dialog);   new Wt::WBreak(dialog);   new Wt::WBreak(dialog);   Wt::WGroupBox * const box = new Wt::WGroupBox("Explanation",dialog);   box->addWidget(new Wt::WImage("ToolTestEncrangerWelcome.png"));   return dialog; } //--------------------------------------------------------------------------- ```

## zip.sh

 ``` #!/bin/sh #zip packs all the files to port into a single .zip file, #minicking the same folder structure #Folder structure # * #   * Classes #     * CppAbout #     * CppEncranger #     * CppLoopReader #     * CppQtAboutDialog #     * CppWtAboutDialog #     * CppWtAutoConfig #   * Tools #    * ToolTestEncranger rm *.user echo "Mimicking file structure" mkdir temp_zip mkdir temp_zip/Classes mkdir temp_zip/Classes/CppAbout mkdir temp_zip/Classes/CppEncranger mkdir temp_zip/Classes/CppLoopReader mkdir temp_zip/Classes/CppQtAboutDialog mkdir temp_zip/Classes/CppWtAboutDialog mkdir temp_zip/Classes/CppWtAutoConfig mkdir temp_zip/Tools mkdir temp_zip/Tools/ToolTestEncranger echo "Copying files" cp ../../Classes/CppAbout/*.* temp_zip/Classes/CppAbout cp ../../Classes/CppEncranger/*.* temp_zip/Classes/CppEncranger cp ../../Classes/CppLoopReader/*.* temp_zip/Classes/CppLoopReader cp ../../Classes/CppQtAboutDialog/*.* temp_zip/Classes/CppQtAboutDialog cp ../../Classes/CppWtAboutDialog/*.* temp_zip/Classes/CppWtAboutDialog cp ../../Classes/CppWtAutoConfig/*.* temp_zip/Classes/CppWtAutoConfig cp ../../Tools/ToolTestEncranger/*.* temp_zip/Tools/ToolTestEncranger FILENAME=ToolTestEncrangerSource_2_4 ZIP_FILENAME=\$FILENAME".zip" echo "Remove previous zip" rm \$ZIP_FILENAME #echo "Compressing files" cd temp_zip zip -r \$FILENAME Classes #zip -r \$FILENAME Libraries #zip -r \$FILENAME Projects zip -r \$FILENAME Tools cd .. cp "temp_zip/"\$ZIP_FILENAME \$ZIP_FILENAME echo "Cleaning up" #Classes rm temp_zip/Classes/CppAbout/*.* rm temp_zip/Classes/CppEncranger/*.* rm temp_zip/Classes/CppLoopReader/*.* rm temp_zip/Classes/CppQtAboutDialog/*.* rm temp_zip/Classes/CppWtAboutDialog/*.* rm temp_zip/Classes/CppWtAutoConfig/*.* rmdir temp_zip/Classes/CppAbout rmdir temp_zip/Classes/CppEncranger rmdir temp_zip/Classes/CppLoopReader rmdir temp_zip/Classes/CppQtAboutDialog rmdir temp_zip/Classes/CppWtAboutDialog rmdir temp_zip/Classes/CppWtAutoConfig rmdir temp_zip/Classes #Tools rm temp_zip/Tools/ToolTestEncranger/*.* rmdir temp_zip/Tools/ToolTestEncranger rmdir temp_zip/Tools rm temp_zip/*.* rmdir temp_zip echo "Done" ```