Advertisement
Guest User

encryptmy.cpp

a guest
Jun 28th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "encryptmy.h"
  2. #include <stdlib.h>
  3.  
  4. enCryptMy::enCryptMy(QObject *parent) : QObject(parent)
  5. {
  6.  
  7. }
  8.  
  9. void enCryptMy::EncrpytMy(QString encryptText, QString localizationToSave)
  10. {
  11.     //variables for converting text to int
  12.     QString localization = localizationToSave;
  13.     QString texxt = encryptText;
  14.     QChar test;
  15.    QList <int> intArray[texxt.length()]; //converted text in ASCII format
  16.     //converting...
  17.     if (texxt.isNull())
  18.     {
  19.         return;
  20.     }
  21.     else
  22.     {
  23.         for (int d=0; d <texxt.size();d++)
  24.         {
  25.             test = texxt.at(d);
  26.             intArray[0].append(0);
  27.             intArray[d+1].append(test.toLatin1());
  28.             qDebug()<<"the code to start mission 'Mars Revolution' is :" <<intArray[d +1];
  29.         }
  30.     }
  31.     //making image
  32.     int index = 0;
  33.     int width = texxt.length();
  34.     int isok = texxt.length() % 4
  35.     qDebug()<<"width: "<<width;
  36.  
  37.     QRgb value =0;
  38.     QImage img(width,width,QImage::Format_ARGB32);
  39.  
  40.     if (isok==0)
  41.     {
  42.         for (int w = 1; w <=texxt.length(); w++)
  43.         {
  44.             //converting ints to pixels
  45.             index = w * 4;
  46.             value = qRgba(intArray[index-3], intArray[index-2], intArray[index-1],intArray[index]);
  47.             //setting pixels
  48.             img.setPixel(w,1,value);
  49.             qDebug()<<"value :"<<value; // let's see if this  is working
  50.         }
  51.         img.save("test.png"); // dunno where it saves the file, or even if it saves... It's a mystery!
  52.     }
  53.     else
  54.     {
  55.         //code to add the result of modulo to list, just to protect it from buga
  56.  
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement