Skip to content

Commit

Permalink
v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
red-sayed committed Feb 2, 2022
1 parent 13704ec commit c4f0a71
Show file tree
Hide file tree
Showing 27 changed files with 199 additions and 275 deletions.
16 changes: 8 additions & 8 deletions Res-crypt/Hex.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <string>

#define REDHEX_VERSION "1.0"
#define REDHEX_VERSION "1.1"

namespace Red {
/**
Expand All @@ -22,16 +22,16 @@ namespace Red {
*
* @return String with hex result.
*/
inline std::string GetHexArray(const std::string_view a) {
std::string Result = "";
inline std::string * GetHexArray(const std::string_view a) {
std::string *Result = new std::string;

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

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

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

return Result;
Expand All @@ -44,8 +44,8 @@ namespace Red {
*
* @return Normal string.
*/
inline std::string GetStrArray(const std::string_view a) {
std::string Result = "";
inline std::string * GetStrArray(const std::string_view a) {
std::string *Result = new std::string;

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

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

Result.push_back((char) num);
Result->push_back((char) num);
}

return Result;
Expand Down
176 changes: 50 additions & 126 deletions Res-crypt/Res-crypt.pro.user

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Res-crypt/Res/ResCBC1024.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ inline static void RES_CBC_decrypt_buffer(struct RES_ctx_CBC_1024 *ctx, uint8_t
*
* @return Encrypted string
*/
const std::string Red::EncryptResCBC1024(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string Encrypted = "";
std::string * Red::EncryptResCBC1024(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string *Encrypted = new std::string;

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

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

Encrypted.append(Block);
Encrypted->append(Block);
}

return Encrypted;
Expand All @@ -216,9 +216,9 @@ const std::string Red::EncryptResCBC1024(const std::string& in, const std::strin
*
* @return Decrypted string
*/
const std::string Red::DecryptResCBC1024(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string Decrypted = "";
std::string * Red::DecryptResCBC1024(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string *Decrypted = new std::string;

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

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

Decrypted.append(Block);
Decrypted->append(Block);
}

return Decrypted;
Expand Down
4 changes: 2 additions & 2 deletions Res-crypt/Res/ResCBC1024.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Red {
*
* @return Encrypted string
*/
const std::string EncryptResCBC1024(
std::string * EncryptResCBC1024(
const std::string& in,
const std::string_view key,
const std::string_view iv
Expand All @@ -37,7 +37,7 @@ namespace Red {
*
* @return Decrypted string
*/
const std::string DecryptResCBC1024(
std::string * DecryptResCBC1024(
const std::string& in,
const std::string_view key,
const std::string_view iv
Expand Down
16 changes: 8 additions & 8 deletions Res-crypt/Res/ResCBC1536.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ inline static void RES_CBC_decrypt_buffer(struct RES_ctx_CBC_1536 *ctx, uint8_t
*
* @return Encrypted string
*/
const std::string Red::EncryptResCBC1536(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string Encrypted = "";
std::string * Red::EncryptResCBC1536(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string *Encrypted = new std::string;

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

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

Encrypted.append(Block);
Encrypted->append(Block);
}

return Encrypted;
Expand All @@ -216,9 +216,9 @@ const std::string Red::EncryptResCBC1536(const std::string& in, const std::strin
*
* @return Decrypted string
*/
const std::string Red::DecryptResCBC1536(const std::string &in, const std::string_view key,
const std::string_view iv) {
std::string Decrypted = "";
std::string * Red::DecryptResCBC1536(const std::string &in, const std::string_view key,
const std::string_view iv) {
std::string *Decrypted = new std::string;

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

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

Decrypted.append(Block);
Decrypted->append(Block);
}

return Decrypted;
Expand Down
4 changes: 2 additions & 2 deletions Res-crypt/Res/ResCBC1536.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Red {
*
* @return Encrypted string
*/
const std::string EncryptResCBC1536(
std::string * EncryptResCBC1536(
const std::string& in,
const std::string_view key,
const std::string_view iv
Expand All @@ -37,7 +37,7 @@ namespace Red {
*
* @return Decrypted string
*/
const std::string DecryptResCBC1536(
std::string * DecryptResCBC1536(
const std::string& in,
const std::string_view key,
const std::string_view iv
Expand Down
16 changes: 8 additions & 8 deletions Res-crypt/Res/ResCBC512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ inline static void RES_CBC_decrypt_buffer(struct RES_ctx_CBC_512 *ctx, uint8_t *
*
* @return Encrypted string
*/
const std::string Red::EncryptResCBC512(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string Encrypted = "";
std::string * Red::EncryptResCBC512(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string *Encrypted = new std::string;

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

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

Encrypted.append(Block);
Encrypted->append(Block);
}

return Encrypted;
Expand All @@ -216,9 +216,9 @@ const std::string Red::EncryptResCBC512(const std::string& in, const std::string
*
* @return Decrypted string
*/
const std::string Red::DecryptResCBC512(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string Decrypted = "";
std::string * Red::DecryptResCBC512(const std::string& in, const std::string_view key,
const std::string_view iv) {
std::string *Decrypted = new std::string;

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

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

Decrypted.append(Block);
Decrypted->append(Block);
}

return Decrypted;
Expand Down
4 changes: 2 additions & 2 deletions Res-crypt/Res/ResCBC512.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Red {
*
* @return Encrypted string
*/
const std::string EncryptResCBC512(
std::string * EncryptResCBC512(
const std::string& in,
const std::string_view key,
const std::string_view iv
Expand All @@ -37,7 +37,7 @@ namespace Red {
*
* @return Decrypted string
*/
const std::string DecryptResCBC512(
std::string * DecryptResCBC512(
const std::string& in,
const std::string_view key,
const std::string_view iv
Expand Down
12 changes: 6 additions & 6 deletions Res-crypt/Res/ResECB1024.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ inline static void RES_ECB_decrypt(const struct RES_ctx_ECB_1024 *ctx, uint8_t *
*
* @return Encrypted string
*/
const std::string Red::EncryptResECB1024(const std::string& in, const std::string_view key) {
std::string Encrypted = "";
std::string * Red::EncryptResECB1024(const std::string& in, const std::string_view key) {
std::string *Encrypted = new std::string;

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

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

Encrypted.append(Block);
Encrypted->append(Block);
}

return Encrypted;
Expand All @@ -194,8 +194,8 @@ const std::string Red::EncryptResECB1024(const std::string& in, const std::strin
*
* @return Decrypted string
*/
const std::string Red::DecryptResECB1024(const std::string& in, const std::string_view key) {
std::string Decrypted = "";
std::string * Red::DecryptResECB1024(const std::string& in, const std::string_view key) {
std::string *Decrypted = new std::string;

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

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

Decrypted.append(Block);
Decrypted->append(Block);
}

return Decrypted;
Expand Down
4 changes: 2 additions & 2 deletions Res-crypt/Res/ResECB1024.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Red {
*
* @return Encrypted string
*/
const std::string EncryptResECB1024(const std::string& in, const std::string_view key);
std::string * EncryptResECB1024(const std::string& in, const std::string_view key);

/**
* @brief EncryptResECB1024
Expand All @@ -33,7 +33,7 @@ namespace Red {
*
* @return Decrypted string
*/
const std::string DecryptResECB1024(const std::string& in, const std::string_view key);
std::string * DecryptResECB1024(const std::string& in, const std::string_view key);
}

#endif // RED_RESECB1024_H
12 changes: 6 additions & 6 deletions Res-crypt/Res/ResECB1536.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ inline static void RES_ECB_decrypt(const struct RES_ctx_ECB_1536 *ctx, uint8_t *
*
* @return Encrypted string
*/
const std::string Red::EncryptResECB1536(const std::string& in, const std::string_view key) {
std::string Encrypted = "";
std::string * Red::EncryptResECB1536(const std::string& in, const std::string_view key) {
std::string *Encrypted = new std::string;

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

Expand Down Expand Up @@ -179,7 +179,7 @@ const std::string Red::EncryptResECB1536(const std::string& in, const std::strin
RES_init_ctx(&ctx, (const uint8_t *) key.data());
RES_ECB_encrypt(&ctx, (uint8_t *) Block.data());

Encrypted.append(Block);
Encrypted->append(Block);
}

return Encrypted;
Expand All @@ -194,8 +194,8 @@ const std::string Red::EncryptResECB1536(const std::string& in, const std::strin
*
* @return Decrypted string
*/
const std::string Red::DecryptResECB1536(const std::string& in, const std::string_view key) {
std::string Decrypted = "";
std::string * Red::DecryptResECB1536(const std::string& in, const std::string_view key) {
std::string *Decrypted = new std::string;

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

Expand Down Expand Up @@ -225,7 +225,7 @@ const std::string Red::DecryptResECB1536(const std::string& in, const std::strin
RES_init_ctx(&ctx, (const uint8_t *) key.data());
RES_ECB_decrypt(&ctx, (uint8_t *) Block.data());

Decrypted.append(Block);
Decrypted->append(Block);
}

return Decrypted;
Expand Down
4 changes: 2 additions & 2 deletions Res-crypt/Res/ResECB1536.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Red {
*
* @return Encrypted string
*/
const std::string EncryptResECB1536(const std::string& in, const std::string_view key);
std::string * EncryptResECB1536(const std::string& in, const std::string_view key);

/**
* @brief EncryptResECB1536
Expand All @@ -33,7 +33,7 @@ namespace Red {
*
* @return Decrypted string
*/
const std::string DecryptResECB1536(const std::string& in, const std::string_view key);
std::string * DecryptResECB1536(const std::string& in, const std::string_view key);
}

#endif // RED_RESECB1536_H
12 changes: 6 additions & 6 deletions Res-crypt/Res/ResECB512.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ inline static void RES_ECB_decrypt(const struct RES_ctx_ECB_512 *ctx, uint8_t *b
*
* @return Encrypted string
*/
const std::string Red::EncryptResECB512(const std::string& in, const std::string_view key) {
std::string Encrypted = "";
std::string * Red::EncryptResECB512(const std::string& in, const std::string_view key) {
std::string *Encrypted = new std::string;

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

Expand Down Expand Up @@ -179,7 +179,7 @@ const std::string Red::EncryptResECB512(const std::string& in, const std::string
RES_init_ctx(&ctx, (const uint8_t *) key.data());
RES_ECB_encrypt(&ctx, (uint8_t *) Block.data());

Encrypted.append(Block);
Encrypted->append(Block);
}

return Encrypted;
Expand All @@ -194,8 +194,8 @@ const std::string Red::EncryptResECB512(const std::string& in, const std::string
*
* @return Decrypted string
*/
const std::string Red::DecryptResECB512(const std::string& in, const std::string_view key) {
std::string Decrypted = "";
std::string * Red::DecryptResECB512(const std::string& in, const std::string_view key) {
std::string *Decrypted = new std::string;

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

Expand Down Expand Up @@ -225,7 +225,7 @@ const std::string Red::DecryptResECB512(const std::string& in, const std::string
RES_init_ctx(&ctx, (const uint8_t *) key.data());
RES_ECB_decrypt(&ctx, (uint8_t *) Block.data());

Decrypted.append(Block);
Decrypted->append(Block);
}

return Decrypted;
Expand Down
Loading

0 comments on commit c4f0a71

Please sign in to comment.