interfaz
Last change
on this file since ec3ce2c was
ec3ce2c,
checked in by aaraujo <aaraujo@…>, 8 years ago
|
Asignado nombres al archivo de entrada y salida del proceso de cifrado
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Rev | Line | |
---|
[b939736] | 1 | #include <QCoreApplication> |
---|
| 2 | #include <QTime> |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | #define _CRT_SECURE_NO_WARNINGS |
---|
| 6 | |
---|
| 7 | #include <iostream> |
---|
| 8 | #include <ctime> |
---|
| 9 | #include "polynomial.h" |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | |
---|
[130b818] | 13 | |
---|
[b939736] | 14 | using namespace std; |
---|
| 15 | using namespace pol; |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | int main(int argc, char *argv[]) |
---|
| 19 | { |
---|
| 20 | QCoreApplication a(argc, argv); |
---|
| 21 | |
---|
| 22 | //return a.exec(); |
---|
| 23 | |
---|
| 24 | if (argc > 0 && argv) { |
---|
| 25 | try { |
---|
| 26 | hash_nm::precalc_mul_table(); |
---|
| 27 | |
---|
[ec3ce2c] | 28 | FILE *fout = fopen("encryptedMessage", "wb"); |
---|
| 29 | File in("message.txt", READ); |
---|
[b939736] | 30 | |
---|
| 31 | pol_t kx = get_rand_pol(KEY_DEG, false); |
---|
| 32 | pol_t ky = get_rand_pol(KEY_DEG, false); |
---|
| 33 | |
---|
| 34 | QTime timer; |
---|
| 35 | timer.start(); |
---|
| 36 | |
---|
| 37 | // generacion de clave? |
---|
| 38 | pol3v_t D = get_open_key(kx, ky); |
---|
| 39 | |
---|
| 40 | int runtime = timer.elapsed(); //gets the runtime in ms |
---|
| 41 | qDebug(qPrintable("key generation: "+QString::number(runtime)+" ms")); |
---|
| 42 | |
---|
| 43 | timer.start(); |
---|
| 44 | encrypt(in, fout, D); |
---|
| 45 | runtime = timer.elapsed(); //gets the runtime in ms |
---|
| 46 | qDebug(qPrintable("encryption duration: "+QString::number(runtime)+" ms")); |
---|
| 47 | |
---|
| 48 | fclose(fout); |
---|
| 49 | in.~File(); |
---|
| 50 | |
---|
[ec3ce2c] | 51 | FILE *fin = fopen("encryptedMessage", "rb"); |
---|
| 52 | File out("decryptedMessage.txt", WRITE); |
---|
[b939736] | 53 | |
---|
| 54 | timer.start(); |
---|
| 55 | decrypt(fin, out, kx, ky); |
---|
| 56 | runtime = timer.elapsed(); //gets the runtime in ms |
---|
| 57 | qDebug(qPrintable("decryption duration: "+QString::number(runtime)+" ms")); |
---|
| 58 | |
---|
| 59 | fclose(fin); |
---|
| 60 | out.close(); |
---|
| 61 | |
---|
| 62 | } |
---|
| 63 | catch (char *str) { |
---|
| 64 | |
---|
| 65 | printf("exception"); |
---|
| 66 | |
---|
| 67 | cout << str << endl; |
---|
| 68 | |
---|
| 69 | qDebug("catch"); |
---|
| 70 | |
---|
| 71 | scanf("\n"); |
---|
| 72 | } |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | |
---|
| 77 | qDebug("salida."); |
---|
| 78 | |
---|
| 79 | return 0; |
---|
| 80 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.