text: #pragma once
  
  #include <thread>//TODO implement calculations in some thread
  #include <stdio.h>
  #include <stdlib.h>
  
  #include <imgui/imgui.h>
  #include <imgui/imgui_stdlib.h>
  
  
  #include "../crypto.h"
  #include "../imgui_helpers.h"
  
  
  void RC4cipher()//RC4 cipher
  {
              ImGui::Begin("RC4 cipher");//vanilla
  
              static std::string plaintext                = "This is the plaintext";
              static std::string password;
              static std::string ciphertext               = "This will be the ciphertext";
              static std::string hex_ciphertext           = "This will be the ciphertext";
  
              static std::string *S0_array;
              static std::string dec_S0_array             = "This is First State Array S[0]";
              static std::string hex_S0_array             = "This is First State Array S[0]";
  
              static uint8_t tmepS0array[256];
              static std::stringstream tempStream;
  
              enum class Bases
              {
                  hex, dec
              };
  
              static Bases showInBase = Bases::dec;
  
              if(showInBase == Bases::dec)
              {
                  S0_array = &dec_S0_array;
              }
              else if (showInBase == Bases::hex)
              {
                  S0_array = &hex_S0_array;
              }
              
  
              ImGui::PushItemWidth(ImGui::GetFontSize() * -10);               // Use fixed width for labels (by passing a negative value), the rest goes to widgets. We choose a width proportional to our font size.
  
  
  
              if(ImGui::InputTextWithHint("Password","password", &password))
              {
                  if(password.length() > 0)
                  {
                      RC4 cipher(password);
                      
                      cipher.getStateArray(tmepS0array);                      //get the S[0] array
                      
                      //convert S[0] array to string
                      tempStream.str(std::string());                          //clearing the stream
                      for (size_t i = 0; i < 256; i++)
                      {
                          tempStream << tmepS0array[i];
                      }
                      hex_S0_array = string2hexstring(tempStream.str());
                      
                      tempStream.str(std::string());                          //clearing the stream
                      for (size_t i = 0; i < 256; i++)
                      {
                          tempStream << (unsigned int)tmepS0array[i] << " ";
                      }
                      dec_S0_array = tempStream.str();
  
                      ciphertext = plaintext;
                      cipher.inplaceCipher(ciphertext);
                      ciphertext = string2hexstring(ciphertext);
                  }
              }
  
              if (ImGui::RadioButton("Hex", showInBase == Bases::hex)) { showInBase = Bases::hex;} ImGui::SameLine();
              if (ImGui::RadioButton("Dec", showInBase == Bases::dec)) { showInBase = Bases::dec;}
  
              //ImGui::InputTextMultiline("First State Array", S0_array, ImVec2(0,60),ImGuiInputTextFlags_ReadOnly);
              
              //TODO make this render more pretty, like an input or something
              ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x * 0.7f);
              ImGui::Text( S0_array->c_str() );
              ImGui::PopTextWrapPos();
              ImGui::SameLine();
              ImGui::Text("First State Array");
  
              if (ImGui::InputTextMultiline("Plaintext", &plaintext, ImVec2(0,60)))
              {
                  if(password.length() > 0)
                  {
                      RC4 cipher(password);
                      cipher.getStateArray(tmepS0array);//get the S[0] array
                      ciphertext = plaintext;
                      cipher.inplaceCipher(ciphertext);
                      ciphertext = string2hexstring(ciphertext);
                  }
              }
  
              if (ImGui::InputTextMultiline("Ciphertext", &ciphertext, ImVec2(0,60),ImGuiInputTextFlags_CharsHexadecimal))
              {
                  if(password.length() > 0)
                  {
                      RC4 decipher(password);
                      plaintext = hexstring2asciistring(ciphertext);
                      decipher.inplaceCipher(plaintext);
                  }
              }
  
              ImGui::End();//vanilla
  }