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
install-cacic/install-cacic.pro.user
src/CACIC_comm.h
... | ... | @@ -79,6 +79,12 @@ public: |
79 | 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 | 88 | bool commStatus(){ |
83 | 89 | // cria um event-loop temporario |
84 | 90 | QEventLoop eventLoop; | ... | ... |
src/ccacic.cpp
... | ... | @@ -102,8 +102,17 @@ bool CCacic::deleteFile(QString path) |
102 | 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 | 116 | std::string str_out; |
108 | 117 | CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption encryption((byte*)key.toStdString().c_str(), key.length(), (byte*)iv.toStdString().c_str()); |
109 | 118 | CryptoPP::StringSource encryptor(str_in.toStdString(), true, |
... | ... | @@ -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 | 141 | std::string str_out; |
124 | 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 | 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 | 154 | /*Getters/Setters | ... | ... |