Index: interfaz/main.cpp
===================================================================
--- interfaz/main.cpp	(revision 25a5325e8faab321fb5f106ccbd59e88e0854f29)
+++ interfaz/main.cpp	(revision 25a5325e8faab321fb5f106ccbd59e88e0854f29)
@@ -0,0 +1,232 @@
+#include <QApplication>
+#include <QProgressBar>
+#include <QDebug>
+#include <QLabel>
+#include "sistema.h"
+
+#include <QTime>
+#include <QHash>
+#include <QCryptographicHash>
+#include <QFile>
+#include <QTextStream>
+#include <QDateTime>
+#include <QDebug>
+#include <iostream>
+#include <ctime>
+
+#include "polynomial.h"
+#include "executionresult.h"
+
+bool identicalFiles(QString f1, QString f2){
+
+    QCryptographicHash hash1( QCryptographicHash::Sha1 );
+    QCryptographicHash hash2( QCryptographicHash::Sha1 );
+
+    QFile file1( f1 );
+
+    if ( file1.open( QIODevice::ReadOnly ) ) {
+        hash1.addData( file1.readAll() );
+    } else {
+        // Handle "cannot open file" error
+    }
+
+    QFile file2( f2 );
+
+    if ( file2.open( QIODevice::ReadOnly ) ) {
+        hash2.addData( file2.readAll() );
+    } else {
+        // Handle "cannot open file" error
+    }
+
+    if (hash1.result() == hash2.result()){
+        qDebug("  hash1.result() == hash2.result()");
+        return true;
+    }
+    else{
+        qDebug(" diferentes");
+        return false;
+    }
+
+
+    // Retrieve the SHA1 signature of the file
+    //QByteArray sig = hash.result();
+}
+
+
+using namespace std;
+using namespace pol;
+
+
+int main(int argc, char *argv[])
+{
+
+    QApplication a(argc, argv);
+
+
+    QLabel hw("hola mundo");
+    Sistema w;
+    w.show();
+
+    int invalidCount = 0;
+
+    qDebug() << argc;
+
+    qDebug() << argc;
+    return a.exec();
+
+    if (argc > 0 && argv) {
+        try {
+            hash_nm::precalc_mul_table();
+
+            QTime timer;
+            QHash<int, ExecutionResult*> results;
+
+
+            int keyTime = 0;
+            int encryptionTime = 0;
+            int decryptionTime = 0;
+
+            // repeticiones
+            //for (int i = 0; i < 50; i++){
+
+            for(int i=1;i<=8;i++) {
+
+                QString messageFile = "message";
+                QString textEncrip = "encryptedMessage";
+                QString textDecrip = "decryptedMessage";
+                messageFile.append(QString::number(i));
+                textEncrip.append(QString::number(i));
+                textDecrip.append(QString::number(i));
+
+                qDebug("generar archivo...");
+                // generar registros en archivo de texto
+                QString fileName = "registro-superficie-";
+                fileName.append(messageFile+"-");
+                fileName.append(QDateTime::currentDateTime().toString("dd.MM.yy.hh.mm.ss"));
+                fileName.append(".txt");
+
+                messageFile.append(".txt");
+                textEncrip.append(".txt");
+                textDecrip.append(".txt");
+                //qDebug("antes del while");
+                int validCount = 0;
+
+                while ( true ) {
+
+                    FILE *fout = fopen(qPrintable(textEncrip), "wb");
+                    QFile file( qPrintable(messageFile) );
+
+                    if ( file.open(QIODevice::ReadWrite) )
+                    {
+                        QTextStream stream( &file );
+                        stream << "something" << endl;
+                    }
+
+                    //File in("message1.txt", READ);
+                    //qDebug(qPrintable(messageFile));
+                    File in(qPrintable(messageFile), READ);
+
+                    pol_t kx = get_rand_pol(KEY_DEG, false);
+                    pol_t ky = get_rand_pol(KEY_DEG, false);
+
+                    // generacion de clave?
+                    timer.start();
+                    pol3v_t D = get_open_key(kx, ky);
+                    keyTime = timer.elapsed(); //gets the runtime in ms
+
+                    // cifrado
+                    timer.start();
+                    encrypt(in, fout, D);
+                    encryptionTime = timer.elapsed(); //gets the runtime in ms
+
+                    fclose(fout);
+                    in.~File();
+
+                    FILE *fin = fopen(qPrintable(textEncrip), "rb");
+                    File out(qPrintable(textDecrip), WRITE);
+
+                    // descifrado
+                    timer.start();
+                    decrypt(fin, out, kx, ky);
+                    decryptionTime = timer.elapsed(); //gets the runtime in ms
+
+                    fclose(fin);
+                    out.close();
+
+                    // verificacion
+                    //if (identicalFiles("message1.txt", "decryptedMessage.txt")){
+                    if (identicalFiles(qPrintable(messageFile), qPrintable(textDecrip))) {
+                        validCount++;
+                        ExecutionResult * execution = new ExecutionResult(keyTime, encryptionTime, decryptionTime);
+                        results.insert(validCount, execution);
+
+                    }
+                    else{
+                        invalidCount++;
+                    }
+
+                    //validCount++;
+                    if (validCount == 1) {
+
+                        //qDebug("generar archivo...");
+                        // generar registros en archivo de texto
+                        //QString fileName = "registro-";
+                        //fileName.append(QDateTime::currentDateTime().toString("dd.MM.yy.hh.mm.ss"));
+                        //fileName.append(".txt");
+
+                        QFile registerFile(fileName);
+                        if (registerFile.open(QFile::WriteOnly)) {
+                            QTextStream out(&registerFile);
+
+                            //out << "Result: " << qSetFieldWidth(10) << left << 3.14 << 2.7;
+                            // writes "Result: 3.14      2.7       "
+
+                            QString line;
+                            for (int j = 1; j <= validCount; j++) {
+                                ExecutionResult * x = results.value(j);
+                                int k = x->getKeyGenerationTime();
+                                //qDebug("k: %d",k);
+
+                                int e = x->getEncryptionTime();
+                                //qDebug("e: %d",e);
+
+                                int d = x->getDecryptionTime();
+                                //qDebug("d: %d",d);
+
+                                line = QString::number(k) + " " + QString::number(e) + " " + QString::number(d) + "\n";
+                                //qDebug(qPrintable(line));
+                                out << line;
+                                line.clear();
+                            }
+
+                        }
+
+                    qDebug("Fin del while");
+                    break;
+                }
+
+
+            }
+
+       }
+
+
+     }
+        catch (char *str) {
+
+            printf("exception");
+
+            cout << str << endl;
+
+            qDebug("catch");
+
+            scanf("\n");
+        }
+    }
+    qDebug("invalidCount %d", invalidCount);
+    qDebug("Salida Final.");
+
+    return a.exec();
+}
+
+
