Commit 9c4df83dc1f852e24b70f6c2e08a465b53056283
1 parent
70143f74
Exists in
master
adicionado documentação em comentarios
Showing
4 changed files
with
33 additions
and
10 deletions
Show diff stats
cacic-teste/cacic-teste.pro.user
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!DOCTYPE QtCreatorProject> | 2 | <!DOCTYPE QtCreatorProject> |
3 | -<!-- Written by QtCreator 3.1.2, 2014-07-17T18:11:35. --> | 3 | +<!-- Written by QtCreator 3.1.2, 2014-07-22T12:25:15. --> |
4 | <qtcreator> | 4 | <qtcreator> |
5 | <data> | 5 | <data> |
6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> | 6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
install-cacic/install-cacic.pro.user
1 | <?xml version="1.0" encoding="UTF-8"?> | 1 | <?xml version="1.0" encoding="UTF-8"?> |
2 | <!DOCTYPE QtCreatorProject> | 2 | <!DOCTYPE QtCreatorProject> |
3 | -<!-- Written by QtCreator 3.1.2, 2014-07-17T18:11:35. --> | 3 | +<!-- Written by QtCreator 3.1.2, 2014-07-21T17:43:51. --> |
4 | <qtcreator> | 4 | <qtcreator> |
5 | <data> | 5 | <data> |
6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> | 6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
src/CACIC_comm.h
@@ -79,6 +79,12 @@ public: | @@ -79,6 +79,12 @@ public: | ||
79 | return retorno; | 79 | return retorno; |
80 | } | 80 | } |
81 | 81 | ||
82 | + | ||
83 | + /* commStatus | ||
84 | + * execulta um teste do tipo GET na urlGerente; | ||
85 | + * @return retorna o resultado da conexão HTTP: | ||
86 | + * exemplo: 200 OK | ||
87 | + */ | ||
82 | bool commStatus(){ | 88 | bool commStatus(){ |
83 | // cria um event-loop temporario | 89 | // cria um event-loop temporario |
84 | QEventLoop eventLoop; | 90 | QEventLoop eventLoop; |
src/ccacic.cpp
@@ -102,8 +102,17 @@ bool CCacic::deleteFile(QString path) | @@ -102,8 +102,17 @@ bool CCacic::deleteFile(QString path) | ||
102 | return true; | 102 | return true; |
103 | } | 103 | } |
104 | 104 | ||
105 | -std::string CCacic::enCrypt(QString str_in, QString key, QString iv) | ||
106 | -{ | 105 | + |
106 | +/*enCrypt | ||
107 | + * @parameter QString str_in: string que será encriptada (url). | ||
108 | + * QString key: chave utilizada na encriptação (32 caracteres) 32*8 = 256 bits | ||
109 | + * *exemplo: qwertyuiopasdfghjklzxcvbnmqwerty | ||
110 | + * QString iv: IV (Vetor de Inicialização) deve ser aleatório. | ||
111 | + * (http://pt.wikipedia.org/wiki/Modo_de_opera%C3%A7%C3%A3o_%28criptografia%29#Vetor_de_inicializa.C3.A7.C3.A3o_.28IV.29) | ||
112 | + * exemplo de iv: 0123456789123456 | ||
113 | + * @return std:string: retorna a string encriptada convertida em base64. | ||
114 | + * */ | ||
115 | +QString CCacic::enCrypt(QString str_in, QString key, QString iv) { | ||
107 | std::string str_out; | 116 | std::string str_out; |
108 | CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption encryption((byte*)key.toStdString().c_str(), key.length(), (byte*)iv.toStdString().c_str()); | 117 | CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption encryption((byte*)key.toStdString().c_str(), key.length(), (byte*)iv.toStdString().c_str()); |
109 | CryptoPP::StringSource encryptor(str_in.toStdString(), true, | 118 | CryptoPP::StringSource encryptor(str_in.toStdString(), true, |
@@ -114,12 +123,21 @@ std::string CCacic::enCrypt(QString str_in, QString key, QString iv) | @@ -114,12 +123,21 @@ std::string CCacic::enCrypt(QString str_in, QString key, QString iv) | ||
114 | ) | 123 | ) |
115 | ) | 124 | ) |
116 | ); | 125 | ); |
117 | - qDebug(QString::fromStdString(str_out).toLocal8Bit()); | ||
118 | - return str_out; | 126 | + //qDebug(QString::fromStdString(str_out).toLocal8Bit()); |
127 | + return QString::fromStdString(str_out).toLocal8Bit(); | ||
119 | } | 128 | } |
120 | 129 | ||
121 | -std::string CCacic::deCrypt(QString str_in, QString key, QString iv) | ||
122 | -{ | 130 | +/*deCrypt |
131 | + * @parameter QString str_in: string encriptada convertida em base64. | ||
132 | + * QString key: chave utilizada na encriptação (32 caracteres) 32*8 = 256 bits | ||
133 | + * *exemplo: qwertyuiopasdfghjklzxcvbnmqwerty | ||
134 | + * QString iv: IV (Vetor de Inicialização) deve ser aleatório. | ||
135 | + * *Um IV jamais deve ser utilizado mais de uma vez com a mesma chave. | ||
136 | + * *(http://pt.wikipedia.org/wiki/Modo_de_opera%C3%A7%C3%A3o_%28criptografia%29#Vetor_de_inicializa.C3.A7.C3.A3o_.28IV.29) | ||
137 | + * *exemplo de iv: 0123456789123456 | ||
138 | + * @return QString: retorna a string desencriptada convertida em base64. | ||
139 | + * */ | ||
140 | +QString CCacic::deCrypt(QString str_in, QString key, QString iv) { | ||
123 | std::string str_out; | 141 | std::string str_out; |
124 | CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption decryption((byte*)key.toStdString().c_str(), key.length(), (byte*)iv.toStdString().c_str()); | 142 | CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption decryption((byte*)key.toStdString().c_str(), key.length(), (byte*)iv.toStdString().c_str()); |
125 | 143 | ||
@@ -130,8 +148,7 @@ std::string CCacic::deCrypt(QString str_in, QString key, QString iv) | @@ -130,8 +148,7 @@ std::string CCacic::deCrypt(QString str_in, QString key, QString iv) | ||
130 | ) | 148 | ) |
131 | ) | 149 | ) |
132 | ); | 150 | ); |
133 | - qDebug(QString::fromStdString(str_out).toLocal8Bit()); | ||
134 | - return str_out; | 151 | + return QString::fromStdString(str_out).toLocal8Bit(); |
135 | } | 152 | } |
136 | 153 | ||
137 | /*Getters/Setters | 154 | /*Getters/Setters |