Skip to content

Commit b9aaf78

Browse files
author
1415ddfer
committed
remove test mode, add md info
1 parent 6d3fb01 commit b9aaf78

File tree

3 files changed

+91
-87
lines changed

3 files changed

+91
-87
lines changed

MDResources/1.png

1.14 MB
Loading

readme.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ a local launcher of DDTank without install FlashPlayer
44

55
一个无需安装flash player就可以游玩弹弹堂的本地启动器
66

7+
当游戏因为你的文本缩放而出现黑边时请尝试以下办法↓
8+
9+
![黑边解决方法](MDResources/1.png)
10+
711
## Auto Api 脚本接口
812

913
when the program is running, use http://127.0.0.1/7233/nickName/{your_account_nickName}/start

src/main.cpp

+87-87
Original file line numberDiff line numberDiff line change
@@ -16,64 +16,64 @@
1616
// std::cout << "dx:" << i << "\t" << "no solution" << std::endl;
1717
// }
1818
//}
19-
20-
char* hex_encode(unsigned char* data, int len) {
21-
char* hex = (char*)malloc(len * 2 + 1);
22-
for (int i = 0; i < len; i++) {
23-
sprintf(hex + i * 2, "%02x", data[i]);
24-
}
25-
hex[len * 2] = '\0';
26-
return hex;
27-
}
28-
29-
// 使用openssl/evp.h进行AES-256-ECB加密
30-
char* aes_encrypt(const char* plaintext, const char* key) {
31-
// 创建EVP_CIPHER_CTX对象
32-
EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
33-
if (ctx == NULL) {
34-
printf("Failed to create cipher context\n");
35-
return NULL;
36-
}
37-
// 初始化加密上下文,指定加密算法和密钥
38-
if (EVP_EncryptInit_ex(ctx, EVP_aes_256_ecb(), NULL, (unsigned char*)key, NULL) != 1) {
39-
printf("Failed to initialize encryption context\n");
40-
EVP_CIPHER_CTX_free(ctx);
41-
return NULL;
42-
}
43-
// 计算加密后数据的长度
44-
int len = strlen(plaintext) + EVP_CIPHER_block_size(EVP_aes_256_ecb()) - 1;
45-
len -= len % EVP_CIPHER_block_size(EVP_aes_256_ecb());
46-
// 分配输出缓冲区
47-
unsigned char* cipherdata = (unsigned char*)malloc(len);
48-
memset(cipherdata, 0, len);
49-
// 加密数据
50-
int outlen = 0;
51-
if (EVP_EncryptUpdate(ctx, cipherdata, &outlen, (unsigned char*)plaintext, strlen(plaintext)) != 1) {
52-
printf("Failed to encrypt data\n");
53-
free(cipherdata);
54-
EVP_CIPHER_CTX_free(ctx);
55-
return NULL;
56-
}
57-
// 获取加密结果
58-
int lastlen = 0;
59-
if (EVP_EncryptFinal_ex(ctx, cipherdata + outlen, &lastlen) != 1) {
60-
printf("Failed to finalize encryption\n");
61-
free(cipherdata);
62-
EVP_CIPHER_CTX_free(ctx);
63-
return NULL;
64-
}
65-
// 计算加密后数据的总长度
66-
int totallen = outlen + lastlen;
67-
// 将加密后的数据转换为十六进制字符串
68-
char* ciphertext = hex_encode(cipherdata, totallen);
69-
// 释放缓冲区和上下文对象
70-
free(cipherdata);
71-
EVP_CIPHER_CTX_free(ctx);
72-
// 返回加密后的密文
73-
return ciphertext;
74-
}
75-
76-
19+
//
20+
//char* hex_encode(unsigned char* data, int len) {
21+
// char* hex = (char*)malloc(len * 2 + 1);
22+
// for (int i = 0; i < len; i++) {
23+
// sprintf(hex + i * 2, "%02x", data[i]);
24+
// }
25+
// hex[len * 2] = '\0';
26+
// return hex;
27+
//}
28+
//
29+
//// 使用openssl/evp.h进行AES-256-ECB加密
30+
//char* aes_encrypt(const char* plaintext, const char* key) {
31+
// // 创建EVP_CIPHER_CTX对象
32+
// EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
33+
// if (ctx == NULL) {
34+
// printf("Failed to create cipher context\n");
35+
// return NULL;
36+
// }
37+
// // 初始化加密上下文,指定加密算法和密钥
38+
// if (EVP_EncryptInit_ex(ctx, EVP_aes_256_ecb(), NULL, (unsigned char*)key, NULL) != 1) {
39+
// printf("Failed to initialize encryption context\n");
40+
// EVP_CIPHER_CTX_free(ctx);
41+
// return NULL;
42+
// }
43+
// // 计算加密后数据的长度
44+
// int len = strlen(plaintext) + EVP_CIPHER_block_size(EVP_aes_256_ecb()) - 1;
45+
// len -= len % EVP_CIPHER_block_size(EVP_aes_256_ecb());
46+
// // 分配输出缓冲区
47+
// unsigned char* cipherdata = (unsigned char*)malloc(len);
48+
// memset(cipherdata, 0, len);
49+
// // 加密数据
50+
// int outlen = 0;
51+
// if (EVP_EncryptUpdate(ctx, cipherdata, &outlen, (unsigned char*)plaintext, strlen(plaintext)) != 1) {
52+
// printf("Failed to encrypt data\n");
53+
// free(cipherdata);
54+
// EVP_CIPHER_CTX_free(ctx);
55+
// return NULL;
56+
// }
57+
// // 获取加密结果
58+
// int lastlen = 0;
59+
// if (EVP_EncryptFinal_ex(ctx, cipherdata + outlen, &lastlen) != 1) {
60+
// printf("Failed to finalize encryption\n");
61+
// free(cipherdata);
62+
// EVP_CIPHER_CTX_free(ctx);
63+
// return NULL;
64+
// }
65+
// // 计算加密后数据的总长度
66+
// int totallen = outlen + lastlen;
67+
// // 将加密后的数据转换为十六进制字符串
68+
// char* ciphertext = hex_encode(cipherdata, totallen);
69+
// // 释放缓冲区和上下文对象
70+
// free(cipherdata);
71+
// EVP_CIPHER_CTX_free(ctx);
72+
// // 返回加密后的密文
73+
// return ciphertext;
74+
//}
75+
//
76+
//
7777

7878

7979

@@ -89,32 +89,32 @@ int main(int argc, char *argv[])
8989
QApplication::exec();
9090
return 0;
9191
}
92-
93-
void test_aes() {
94-
auto plaintext = QString("123");
95-
auto key = QString("lzYW5qaXVqa");
96-
97-
auto* ciphertext = new unsigned char[plaintext.size() + AES_BLOCK_SIZE];
98-
EVP_CIPHER_CTX *ctx;
99-
ctx = EVP_CIPHER_CTX_new();
100-
101-
auto ba_k = key.toLatin1();
102-
EVP_EncryptInit_ex(
103-
ctx,
104-
EVP_aes_128_cbc(),
105-
nullptr,
106-
(unsigned char*)ba_k.data(),
107-
nullptr);
108-
109-
int len;
110-
auto ba = plaintext.toLatin1();
111-
EVP_EncryptUpdate(ctx, ciphertext, &len,
112-
(unsigned char *)ba.data(), (int)plaintext.size());
113-
EVP_EncryptFinal_ex(ctx, ciphertext + len, &len);
114-
115-
EVP_CIPHER_CTX_free(ctx);
116-
auto ret = QByteArray((char *)ciphertext);
117-
qDebug() << ret.toBase64();
118-
119-
delete[] ciphertext;
120-
}
92+
//
93+
//void test_aes() {
94+
// auto plaintext = QString("123");
95+
// auto key = QString("lzYW5qaXVqa");
96+
//
97+
// auto* ciphertext = new unsigned char[plaintext.size() + AES_BLOCK_SIZE];
98+
// EVP_CIPHER_CTX *ctx;
99+
// ctx = EVP_CIPHER_CTX_new();
100+
//
101+
// auto ba_k = key.toLatin1();
102+
// EVP_EncryptInit_ex(
103+
// ctx,
104+
// EVP_aes_128_cbc(),
105+
// nullptr,
106+
// (unsigned char*)ba_k.data(),
107+
// nullptr);
108+
//
109+
// int len;
110+
// auto ba = plaintext.toLatin1();
111+
// EVP_EncryptUpdate(ctx, ciphertext, &len,
112+
// (unsigned char *)ba.data(), (int)plaintext.size());
113+
// EVP_EncryptFinal_ex(ctx, ciphertext + len, &len);
114+
//
115+
// EVP_CIPHER_CTX_free(ctx);
116+
// auto ret = QByteArray((char *)ciphertext);
117+
// qDebug() << ret.toBase64();
118+
//
119+
// delete[] ciphertext;
120+
//}

0 commit comments

Comments
 (0)