Skip to content

Commit c4f0a71

Browse files
committed
v1.2
1 parent 13704ec commit c4f0a71

27 files changed

+199
-275
lines changed

Res-crypt/Hex.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <string>
1414

15-
#define REDHEX_VERSION "1.0"
15+
#define REDHEX_VERSION "1.1"
1616

1717
namespace Red {
1818
/**
@@ -22,16 +22,16 @@ namespace Red {
2222
*
2323
* @return String with hex result.
2424
*/
25-
inline std::string GetHexArray(const std::string_view a) {
26-
std::string Result = "";
25+
inline std::string * GetHexArray(const std::string_view a) {
26+
std::string *Result = new std::string;
2727

2828
for (unsigned long long int i = 0; i < a.length(); i++) {
2929
char const hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b','c','d','e','f'};
3030

3131
const unsigned char ch = (const unsigned char) a[i];
3232

33-
Result.append(&hex[(ch & 0xF0) >> 4], 1);
34-
Result.append(&hex[ch & 0xF], 1);
33+
Result->append(&hex[(ch & 0xF0) >> 4], 1);
34+
Result->append(&hex[ch & 0xF], 1);
3535
}
3636

3737
return Result;
@@ -44,8 +44,8 @@ namespace Red {
4444
*
4545
* @return Normal string.
4646
*/
47-
inline std::string GetStrArray(const std::string_view a) {
48-
std::string Result = "";
47+
inline std::string * GetStrArray(const std::string_view a) {
48+
std::string *Result = new std::string;
4949

5050
for (unsigned long long int n = 0; n < a.length(); n += 2) {
5151
std::string HexByte = "";
@@ -55,7 +55,7 @@ namespace Red {
5555

5656
int num = std::stoi(HexByte, nullptr, 16);
5757

58-
Result.push_back((char) num);
58+
Result->push_back((char) num);
5959
}
6060

6161
return Result;

Res-crypt/Res-crypt.pro.user

Lines changed: 50 additions & 126 deletions
Large diffs are not rendered by default.

Res-crypt/Res/ResCBC1024.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ inline static void RES_CBC_decrypt_buffer(struct RES_ctx_CBC_1024 *ctx, uint8_t
164164
*
165165
* @return Encrypted string
166166
*/
167-
const std::string Red::EncryptResCBC1024(const std::string& in, const std::string_view key,
168-
const std::string_view iv) {
169-
std::string Encrypted = "";
167+
std::string * Red::EncryptResCBC1024(const std::string& in, const std::string_view key,
168+
const std::string_view iv) {
169+
std::string *Encrypted = new std::string;
170170

171171
unsigned long long int InLen = in.length();
172172

@@ -201,7 +201,7 @@ const std::string Red::EncryptResCBC1024(const std::string& in, const std::strin
201201
RES_init_ctx_iv(&ctx, (const uint8_t *) key.data(), (const uint8_t *) iv.data());
202202
RES_CBC_encrypt_buffer(&ctx, (uint8_t *) Block.data(), Block.length());
203203

204-
Encrypted.append(Block);
204+
Encrypted->append(Block);
205205
}
206206

207207
return Encrypted;
@@ -216,9 +216,9 @@ const std::string Red::EncryptResCBC1024(const std::string& in, const std::strin
216216
*
217217
* @return Decrypted string
218218
*/
219-
const std::string Red::DecryptResCBC1024(const std::string& in, const std::string_view key,
220-
const std::string_view iv) {
221-
std::string Decrypted = "";
219+
std::string * Red::DecryptResCBC1024(const std::string& in, const std::string_view key,
220+
const std::string_view iv) {
221+
std::string *Decrypted = new std::string;
222222

223223
unsigned long long int InLen = in.length();
224224

@@ -248,7 +248,7 @@ const std::string Red::DecryptResCBC1024(const std::string& in, const std::strin
248248
RES_init_ctx_iv(&ctx, (const uint8_t *) key.data(), (const uint8_t *) iv.data());
249249
RES_CBC_decrypt_buffer(&ctx, (uint8_t *) Block.data(), Block.length());
250250

251-
Decrypted.append(Block);
251+
Decrypted->append(Block);
252252
}
253253

254254
return Decrypted;

Res-crypt/Res/ResCBC1024.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Red {
2222
*
2323
* @return Encrypted string
2424
*/
25-
const std::string EncryptResCBC1024(
25+
std::string * EncryptResCBC1024(
2626
const std::string& in,
2727
const std::string_view key,
2828
const std::string_view iv
@@ -37,7 +37,7 @@ namespace Red {
3737
*
3838
* @return Decrypted string
3939
*/
40-
const std::string DecryptResCBC1024(
40+
std::string * DecryptResCBC1024(
4141
const std::string& in,
4242
const std::string_view key,
4343
const std::string_view iv

Res-crypt/Res/ResCBC1536.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ inline static void RES_CBC_decrypt_buffer(struct RES_ctx_CBC_1536 *ctx, uint8_t
164164
*
165165
* @return Encrypted string
166166
*/
167-
const std::string Red::EncryptResCBC1536(const std::string& in, const std::string_view key,
168-
const std::string_view iv) {
169-
std::string Encrypted = "";
167+
std::string * Red::EncryptResCBC1536(const std::string& in, const std::string_view key,
168+
const std::string_view iv) {
169+
std::string *Encrypted = new std::string;
170170

171171
unsigned long long int InLen = in.length();
172172

@@ -201,7 +201,7 @@ const std::string Red::EncryptResCBC1536(const std::string& in, const std::strin
201201
RES_init_ctx_iv(&ctx, (const uint8_t *) key.data(), (const uint8_t *) iv.data());
202202
RES_CBC_encrypt_buffer(&ctx, (uint8_t *) Block.data(), Block.length());
203203

204-
Encrypted.append(Block);
204+
Encrypted->append(Block);
205205
}
206206

207207
return Encrypted;
@@ -216,9 +216,9 @@ const std::string Red::EncryptResCBC1536(const std::string& in, const std::strin
216216
*
217217
* @return Decrypted string
218218
*/
219-
const std::string Red::DecryptResCBC1536(const std::string &in, const std::string_view key,
220-
const std::string_view iv) {
221-
std::string Decrypted = "";
219+
std::string * Red::DecryptResCBC1536(const std::string &in, const std::string_view key,
220+
const std::string_view iv) {
221+
std::string *Decrypted = new std::string;
222222

223223
unsigned long long int InLen = in.length();
224224

@@ -248,7 +248,7 @@ const std::string Red::DecryptResCBC1536(const std::string &in, const std::strin
248248
RES_init_ctx_iv(&ctx, (const uint8_t *) key.data(), (const uint8_t *) iv.data());
249249
RES_CBC_decrypt_buffer(&ctx, (uint8_t *) Block.data(), Block.length());
250250

251-
Decrypted.append(Block);
251+
Decrypted->append(Block);
252252
}
253253

254254
return Decrypted;

Res-crypt/Res/ResCBC1536.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Red {
2222
*
2323
* @return Encrypted string
2424
*/
25-
const std::string EncryptResCBC1536(
25+
std::string * EncryptResCBC1536(
2626
const std::string& in,
2727
const std::string_view key,
2828
const std::string_view iv
@@ -37,7 +37,7 @@ namespace Red {
3737
*
3838
* @return Decrypted string
3939
*/
40-
const std::string DecryptResCBC1536(
40+
std::string * DecryptResCBC1536(
4141
const std::string& in,
4242
const std::string_view key,
4343
const std::string_view iv

Res-crypt/Res/ResCBC512.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ inline static void RES_CBC_decrypt_buffer(struct RES_ctx_CBC_512 *ctx, uint8_t *
164164
*
165165
* @return Encrypted string
166166
*/
167-
const std::string Red::EncryptResCBC512(const std::string& in, const std::string_view key,
168-
const std::string_view iv) {
169-
std::string Encrypted = "";
167+
std::string * Red::EncryptResCBC512(const std::string& in, const std::string_view key,
168+
const std::string_view iv) {
169+
std::string *Encrypted = new std::string;
170170

171171
unsigned long long int InLen = in.length();
172172

@@ -201,7 +201,7 @@ const std::string Red::EncryptResCBC512(const std::string& in, const std::string
201201
RES_init_ctx_iv(&ctx, (const uint8_t *) key.data(), (const uint8_t *) iv.data());
202202
RES_CBC_encrypt_buffer(&ctx, (uint8_t *) Block.data(), Block.length());
203203

204-
Encrypted.append(Block);
204+
Encrypted->append(Block);
205205
}
206206

207207
return Encrypted;
@@ -216,9 +216,9 @@ const std::string Red::EncryptResCBC512(const std::string& in, const std::string
216216
*
217217
* @return Decrypted string
218218
*/
219-
const std::string Red::DecryptResCBC512(const std::string& in, const std::string_view key,
220-
const std::string_view iv) {
221-
std::string Decrypted = "";
219+
std::string * Red::DecryptResCBC512(const std::string& in, const std::string_view key,
220+
const std::string_view iv) {
221+
std::string *Decrypted = new std::string;
222222

223223
unsigned long long int InLen = in.length();
224224

@@ -248,7 +248,7 @@ const std::string Red::DecryptResCBC512(const std::string& in, const std::string
248248
RES_init_ctx_iv(&ctx, (const uint8_t *) key.data(), (const uint8_t *) iv.data());
249249
RES_CBC_decrypt_buffer(&ctx, (uint8_t *) Block.data(), Block.length());
250250

251-
Decrypted.append(Block);
251+
Decrypted->append(Block);
252252
}
253253

254254
return Decrypted;

Res-crypt/Res/ResCBC512.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Red {
2222
*
2323
* @return Encrypted string
2424
*/
25-
const std::string EncryptResCBC512(
25+
std::string * EncryptResCBC512(
2626
const std::string& in,
2727
const std::string_view key,
2828
const std::string_view iv
@@ -37,7 +37,7 @@ namespace Red {
3737
*
3838
* @return Decrypted string
3939
*/
40-
const std::string DecryptResCBC512(
40+
std::string * DecryptResCBC512(
4141
const std::string& in,
4242
const std::string_view key,
4343
const std::string_view iv

Res-crypt/Res/ResECB1024.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ inline static void RES_ECB_decrypt(const struct RES_ctx_ECB_1024 *ctx, uint8_t *
143143
*
144144
* @return Encrypted string
145145
*/
146-
const std::string Red::EncryptResECB1024(const std::string& in, const std::string_view key) {
147-
std::string Encrypted = "";
146+
std::string * Red::EncryptResECB1024(const std::string& in, const std::string_view key) {
147+
std::string *Encrypted = new std::string;
148148

149149
unsigned long long int InLen = in.length();
150150

@@ -179,7 +179,7 @@ const std::string Red::EncryptResECB1024(const std::string& in, const std::strin
179179
RES_init_ctx(&ctx, (const uint8_t *) key.data());
180180
RES_ECB_encrypt(&ctx, (uint8_t *) Block.data());
181181

182-
Encrypted.append(Block);
182+
Encrypted->append(Block);
183183
}
184184

185185
return Encrypted;
@@ -194,8 +194,8 @@ const std::string Red::EncryptResECB1024(const std::string& in, const std::strin
194194
*
195195
* @return Decrypted string
196196
*/
197-
const std::string Red::DecryptResECB1024(const std::string& in, const std::string_view key) {
198-
std::string Decrypted = "";
197+
std::string * Red::DecryptResECB1024(const std::string& in, const std::string_view key) {
198+
std::string *Decrypted = new std::string;
199199

200200
unsigned long long int InLen = in.length();
201201

@@ -225,7 +225,7 @@ const std::string Red::DecryptResECB1024(const std::string& in, const std::strin
225225
RES_init_ctx(&ctx, (const uint8_t *) key.data());
226226
RES_ECB_decrypt(&ctx, (uint8_t *) Block.data());
227227

228-
Decrypted.append(Block);
228+
Decrypted->append(Block);
229229
}
230230

231231
return Decrypted;

Res-crypt/Res/ResECB1024.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Red {
2222
*
2323
* @return Encrypted string
2424
*/
25-
const std::string EncryptResECB1024(const std::string& in, const std::string_view key);
25+
std::string * EncryptResECB1024(const std::string& in, const std::string_view key);
2626

2727
/**
2828
* @brief EncryptResECB1024
@@ -33,7 +33,7 @@ namespace Red {
3333
*
3434
* @return Decrypted string
3535
*/
36-
const std::string DecryptResECB1024(const std::string& in, const std::string_view key);
36+
std::string * DecryptResECB1024(const std::string& in, const std::string_view key);
3737
}
3838

3939
#endif // RED_RESECB1024_H

0 commit comments

Comments
 (0)