dmpserverdes.h
1.4 KB
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
34
35
36
37
38
39
40
41
42
/**************************************************************************
* file: dmpserverdes.h
* Author: qingxiongf
* Date: 2022-01-13 19:20:26
* Email: qingxiongf@chinadci.com
* copyright: 广州城市信息研究所有限公司
***************************************************************************/
#ifndef __dmpserverdes_h__
#define __dmpserverdes_h__
#include "dmap_server.h"
#include <boost/filesystem.hpp>
#include <unordered_map>
#define ENCRYPTION_MODE 1
#define DECRYPTION_MODE 0
class SERVER_EXPORT DmpServerDes
{
public:
typedef struct
{
unsigned char k[8];
unsigned char c[4];
unsigned char d[4];
} key_set;
bool Encrypt(unsigned char *source, unsigned char *des_key, unsigned char *destination);
bool Decrypt(unsigned char *source, int length, unsigned char *key, unsigned char *destination);
// static std::string RsaBase64Encrypt(const std::string &source, const char* key);
static std::string DesBase64Decrypt(const std::string &source, const char* key);
private:
void generate_key(unsigned char *key);
void generate_sub_keys(unsigned char *main_key, key_set *key_sets);
void process_message(unsigned char *message_piece, unsigned char *processed_piece, key_set *key_sets, int mode);
void copyUChar(unsigned char *data_block, unsigned char *source, int loc, int num);
};
#endif // __dmpserverdes_h__