-
Notifications
You must be signed in to change notification settings - Fork 1
/
Crypto.h
executable file
·63 lines (48 loc) · 1.49 KB
/
Crypto.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include "MD5.h"
#include <openssl\evp.h>
#define USEJSONSPIRIT
//#define USEPTREE
//#define USERAPIDJS
class CCrypto
{
public:
CCrypto(void);
~CCrypto(void);
typedef map<string, string> assocA;
typedef map<string, assocA> assocAA;
typedef map<string, string>::iterator ITassocA;
typedef map<string, assocA>::iterator ITassocAA;
string __b64_encode(const unsigned char *input, int length);
void ComputeHMAC(const char* data, string key, char* result); // for S3
static string mapToPostVars( assocA params );
//we'll just include json here also
static assocA json_read(string);
static assocAA json_read2(string);
static string json_write(assocA);
// and aes of course
static bool initAES();
static string aes_encrypt(string str);
static string aes_encryptData(string str);
static string aes_decrypt(string str);
static string aes_decryptData(string str);
static EVP_CIPHER_CTX en_ctx;
static EVP_CIPHER_CTX de_ctx;
#ifdef USEJSONSPIRIT
static assocA json_readJS(string);
static string json_writeJS(assocA);
#endif
#ifdef USEPTREE
static assocA json_readPT(string);
static string json_writePT(assocA);
#endif
#ifdef USERAPIDJS
static assocA json_readRJ(string);
static string json_writeRJ(assocA);
#endif
static string url_encode(char *str);
static string url_decode(char *str);
static char to_hex(char code);
static char from_hex(char ch);
static string extractTail(string& sbase, string selector);
};