-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcipher.h
33 lines (27 loc) · 845 Bytes
/
cipher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef CIPHER_H
#define CIPHER_H
#include <QString>
#include <QFile>
#include <QDebug>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QtCore/QTextCodec>
#else
#include <QtCore5Compat/QTextCodec>
#endif
#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>
class Cipher
{
public:
Cipher();
~Cipher();
int encrypt_aes128_ecb(unsigned char *plaintext, int plaintext_len, unsigned char *key, unsigned char *ciphertext);
int decrypt_aes128_ecb(unsigned char *ciphertext, int ciphertext_len, unsigned char *key, unsigned char *plaintext);
QByteArray encrypt_aes128_ecb(const QByteArray &plaintext, const QByteArray &key);
QByteArray decrypt_aes128_ecb(const QByteArray &ciphertext, const QByteArray &key);
private:
EVP_CIPHER_CTX *ctx;
void handleErrors(void);
};
#endif // CIPHER_H