diff --git a/Res-crypt/Hex.h b/Res-crypt/Hex.h index 5ec857c..5d4f96d 100644 --- a/Res-crypt/Hex.h +++ b/Res-crypt/Hex.h @@ -12,7 +12,7 @@ #include -#define REDHEX_VERSION "1.0" +#define REDHEX_VERSION "1.1" namespace Red { /** @@ -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; @@ -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 = ""; @@ -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; diff --git a/Res-crypt/Res-crypt.pro.user b/Res-crypt/Res-crypt.pro.user index bc5f29c..980c3e1 100644 --- a/Res-crypt/Res-crypt.pro.user +++ b/Res-crypt/Res-crypt.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -8,7 +8,7 @@ ProjectExplorer.Project.ActiveTarget - 0 + 0 ProjectExplorer.Project.EditorSettings @@ -28,7 +28,7 @@ QmlJSGlobal - 2 + 2 UTF-8 false 4 @@ -37,6 +37,7 @@ true true 1 + false true false 0 @@ -45,6 +46,7 @@ 0 8 true + false 1 true true @@ -59,6 +61,7 @@ true + false true false false @@ -71,6 +74,7 @@ true Builtin.Questionable + false true Builtin.DefaultTidyAndClazy 2 @@ -85,35 +89,28 @@ ProjectExplorer.Project.Target.0 Desktop - Desktop Qt 5.12.3 clang 64bit - Desktop Qt 5.12.3 clang 64bit - qt.qt5.5123.clang_64_kit - 1 - 0 - 0 + Qt 6.1.3 for macOS + Qt 6.1.3 for macOS + qt.qt6.613.clang_64_kit + 0 + 0 + 0 - true 0 - /Volumes/FlashDrive/Repositories/RES_Implementation/build-Res-crypt-Desktop_Qt_5_12_3_clang_64bit-Debug - /Volumes/FlashDrive/Repositories/RES_Implementation/build-Res-crypt-Desktop_Qt_5_12_3_clang_64bit-Debug + /Users/vladimir/Repositories/RES_Implementation/build-Res-crypt-Qt_6_1_3_for_macOS-Debug + /Users/vladimir/Repositories/RES_Implementation/build-Res-crypt-Qt_6_1_3_for_macOS-Debug true QtProjectManager.QMakeBuildStep - false true Qt4ProjectManager.MakeStep - - false - - - false - 2 + 2 Build Build ProjectExplorer.BuildSteps.Build @@ -122,13 +119,9 @@ true Qt4ProjectManager.MakeStep - - true clean - - false - 1 + 1 Clean Clean ProjectExplorer.BuildSteps.Clean @@ -136,36 +129,27 @@ 2 false + false Debug Qt4ProjectManager.Qt4BuildConfiguration 2 - 2 - 2 - true - 2 - /Volumes/FlashDrive/Repositories/build-Res-crypt-Desktop_Qt_5_12_3_clang_64bit-Release - /Volumes/FlashDrive/Repositories/build-Res-crypt-Desktop_Qt_5_12_3_clang_64bit-Release + /Users/vladimir/Repositories/RES_Implementation/build-Res-crypt-Qt_6_1_3_for_macOS-Release + /Users/vladimir/Repositories/RES_Implementation/build-Res-crypt-Qt_6_1_3_for_macOS-Release true QtProjectManager.QMakeBuildStep - false true Qt4ProjectManager.MakeStep - - false - - - false - 2 + 2 Build Build ProjectExplorer.BuildSteps.Build @@ -174,13 +158,9 @@ true Qt4ProjectManager.MakeStep - - true clean - - false - 1 + 1 Clean Clean ProjectExplorer.BuildSteps.Clean @@ -188,36 +168,29 @@ 2 false + false Release Qt4ProjectManager.Qt4BuildConfiguration 0 0 - 2 - true 0 - /Volumes/FlashDrive/Repositories/RES_Implementation/build-Res-crypt-Desktop_Qt_5_12_3_clang_64bit-Profile - /Volumes/FlashDrive/Repositories/RES_Implementation/build-Res-crypt-Desktop_Qt_5_12_3_clang_64bit-Profile + /Users/vladimir/Repositories/RES_Implementation/build-Res-crypt-Qt_6_1_3_for_macOS-Profile + /Users/vladimir/Repositories/RES_Implementation/build-Res-crypt-Qt_6_1_3_for_macOS-Profile true QtProjectManager.QMakeBuildStep - false true Qt4ProjectManager.MakeStep - - false - - - false - 2 + 2 Build Build ProjectExplorer.BuildSteps.Build @@ -226,13 +199,9 @@ true Qt4ProjectManager.MakeStep - - true clean - - false - 1 + 1 Clean Clean ProjectExplorer.BuildSteps.Clean @@ -240,6 +209,7 @@ 2 false + false Profile Qt4ProjectManager.Qt4BuildConfiguration @@ -247,10 +217,10 @@ 0 0 - 3 + 3 - 0 + 0 Deploy Deploy ProjectExplorer.BuildSteps.Deploy @@ -260,90 +230,44 @@ false ProjectExplorer.DefaultDeployConfiguration - 1 - + 1 - dwarf - - cpu-cycles - - - 250 - - -e - cpu-cycles - --call-graph - dwarf,4096 - -F - 250 - - -F true - 4096 - false - false - 1000 - true - - false - false - false - false - true - 0.01 - 10 - true - kcachegrind - 1 - 25 - - 1 true - false - true - valgrind - 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 2 - Qt4ProjectManager.Qt4RunConfiguration:/Volumes/FlashDrive/Repositories/RES_Implementation/Res-crypt/Res-crypt.pro - /Volumes/FlashDrive/Repositories/RES_Implementation/Res-crypt/Res-crypt.pro - - false - + ProjectExplorer.CustomExecutableRunConfiguration + false true - false - true - false false true - - /Volumes/FlashDrive/Repositories - 1 + 1 ProjectExplorer.Project.TargetCount - 1 + 1 ProjectExplorer.Project.Updater.FileVersion diff --git a/Res-crypt/Res/ResCBC1024.cpp b/Res-crypt/Res/ResCBC1024.cpp index d3546ce..74d9687 100644 --- a/Res-crypt/Res/ResCBC1024.cpp +++ b/Res-crypt/Res/ResCBC1024.cpp @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/Res-crypt/Res/ResCBC1024.h b/Res-crypt/Res/ResCBC1024.h index 7adff22..6f0a607 100644 --- a/Res-crypt/Res/ResCBC1024.h +++ b/Res-crypt/Res/ResCBC1024.h @@ -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 @@ -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 diff --git a/Res-crypt/Res/ResCBC1536.cpp b/Res-crypt/Res/ResCBC1536.cpp index d794be6..2d33c44 100644 --- a/Res-crypt/Res/ResCBC1536.cpp +++ b/Res-crypt/Res/ResCBC1536.cpp @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/Res-crypt/Res/ResCBC1536.h b/Res-crypt/Res/ResCBC1536.h index ba9d7d6..4eec2ec 100644 --- a/Res-crypt/Res/ResCBC1536.h +++ b/Res-crypt/Res/ResCBC1536.h @@ -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 @@ -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 diff --git a/Res-crypt/Res/ResCBC512.cpp b/Res-crypt/Res/ResCBC512.cpp index ae893dc..eae4a8a 100644 --- a/Res-crypt/Res/ResCBC512.cpp +++ b/Res-crypt/Res/ResCBC512.cpp @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/Res-crypt/Res/ResCBC512.h b/Res-crypt/Res/ResCBC512.h index 785eebe..f8eadad 100644 --- a/Res-crypt/Res/ResCBC512.h +++ b/Res-crypt/Res/ResCBC512.h @@ -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 @@ -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 diff --git a/Res-crypt/Res/ResECB1024.cpp b/Res-crypt/Res/ResECB1024.cpp index 6a694be..d34427a 100644 --- a/Res-crypt/Res/ResECB1024.cpp +++ b/Res-crypt/Res/ResECB1024.cpp @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/Res-crypt/Res/ResECB1024.h b/Res-crypt/Res/ResECB1024.h index 5178f69..82edcab 100644 --- a/Res-crypt/Res/ResECB1024.h +++ b/Res-crypt/Res/ResECB1024.h @@ -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 @@ -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 diff --git a/Res-crypt/Res/ResECB1536.cpp b/Res-crypt/Res/ResECB1536.cpp index 2ae9744..d8edcf7 100644 --- a/Res-crypt/Res/ResECB1536.cpp +++ b/Res-crypt/Res/ResECB1536.cpp @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/Res-crypt/Res/ResECB1536.h b/Res-crypt/Res/ResECB1536.h index 8015dc5..f0267b4 100644 --- a/Res-crypt/Res/ResECB1536.h +++ b/Res-crypt/Res/ResECB1536.h @@ -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 @@ -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 diff --git a/Res-crypt/Res/ResECB512.cpp b/Res-crypt/Res/ResECB512.cpp index 2a81717..5bb6d1f 100644 --- a/Res-crypt/Res/ResECB512.cpp +++ b/Res-crypt/Res/ResECB512.cpp @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/Res-crypt/Res/ResECB512.h b/Res-crypt/Res/ResECB512.h index b9ccbdd..4e1c827 100644 --- a/Res-crypt/Res/ResECB512.h +++ b/Res-crypt/Res/ResECB512.h @@ -22,7 +22,7 @@ namespace Red { * * @return Encrypted string */ - const std::string EncryptResECB512(const std::string& in, const std::string_view key); + std::string * EncryptResECB512(const std::string& in, const std::string_view key); /** * @brief EncryptResECB512 @@ -33,7 +33,7 @@ namespace Red { * * @return Decrypted string */ - const std::string DecryptResECB512(const std::string& in, const std::string_view key); + std::string * DecryptResECB512(const std::string& in, const std::string_view key); } #endif // RED_RESECB512_H diff --git a/Res-crypt/main.cpp b/Res-crypt/main.cpp index 0140311..704f21a 100644 --- a/Res-crypt/main.cpp +++ b/Res-crypt/main.cpp @@ -112,22 +112,22 @@ int main() { std::cout << "[\033[91mRes\033[0m/\033[94m" + mode + "\033[0m] \033[4mEncrypted message(hex):\033[0m"; if (mode == "CBC-512") { - std::cout << std::endl << std::endl << Red::GetHexArray(Red::EncryptResCBC512(msg, key, iv)); + std::cout << std::endl << std::endl << *Red::GetHexArray(*Red::EncryptResCBC512(msg, key, iv)); } else if (mode == "CBC-1024") { - std::cout << std::endl << std::endl << Red::GetHexArray(Red::EncryptResCBC1024(msg, key, iv)); + std::cout << std::endl << std::endl << *Red::GetHexArray(*Red::EncryptResCBC1024(msg, key, iv)); } else if (mode == "CBC-1536") { - std::cout << std::endl << std::endl << Red::GetHexArray(Red::EncryptResCBC1536(msg, key, iv)); + std::cout << std::endl << std::endl << *Red::GetHexArray(*Red::EncryptResCBC1536(msg, key, iv)); } else if (mode == "ECB-512") { - std::cout << std::endl << std::endl << Red::GetHexArray(Red::EncryptResECB512(msg, key)); + std::cout << std::endl << std::endl << *Red::GetHexArray(*Red::EncryptResECB512(msg, key)); } else if (mode == "ECB-1024") { - std::cout << std::endl << std::endl << Red::GetHexArray(Red::EncryptResECB1024(msg, key)); + std::cout << std::endl << std::endl << *Red::GetHexArray(*Red::EncryptResECB1024(msg, key)); } else if (mode == "ECB-1536") { - std::cout << std::endl << std::endl << Red::GetHexArray(Red::EncryptResECB1536(msg, key)); + std::cout << std::endl << std::endl << *Red::GetHexArray(*Red::EncryptResECB1536(msg, key)); } std::cout << std::endl << std::endl << std::endl << "Press Enter to continue."; @@ -146,28 +146,28 @@ int main() { std::cout << std::endl << std::endl; if (mode == "CBC-512") { - std::string a = Red::GetStrArray(msg.c_str()); - std::cout << Red::DecryptResCBC512(Red::GetStrArray(msg), key, iv); + std::string a = *Red::GetStrArray(msg.c_str()); + std::cout << *Red::DecryptResCBC512(*Red::GetStrArray(msg), key, iv); } else if (mode == "CBC-1024") { - std::string a = Red::GetStrArray(msg.c_str()); - std::cout << Red::DecryptResCBC1024(Red::GetStrArray(msg), key, iv); + std::string a = *Red::GetStrArray(msg.c_str()); + std::cout << *Red::DecryptResCBC1024(*Red::GetStrArray(msg), key, iv); } else if (mode == "CBC-1536") { - std::string a = Red::GetStrArray(msg.c_str()); - std::cout << Red::DecryptResCBC1536(Red::GetStrArray(msg), key, iv); + std::string a = *Red::GetStrArray(msg.c_str()); + std::cout << *Red::DecryptResCBC1536(*Red::GetStrArray(msg), key, iv); } else if (mode == "ECB-512") { - std::string a = Red::GetStrArray(msg.c_str()); - std::cout << Red::DecryptResECB512(Red::GetStrArray(msg), key); + std::string a = *Red::GetStrArray(msg.c_str()); + std::cout << *Red::DecryptResECB512(*Red::GetStrArray(msg), key); } else if (mode == "ECB-1024") { - std::string a = Red::GetStrArray(msg.c_str()); - std::cout << Red::DecryptResECB1024(Red::GetStrArray(msg), key); + std::string a = *Red::GetStrArray(msg.c_str()); + std::cout << *Red::DecryptResECB1024(*Red::GetStrArray(msg), key); } else if (mode == "ECB-1536") { - std::string a = Red::GetStrArray(msg.c_str()); - std::cout << Red::DecryptResECB1536(Red::GetStrArray(msg), key); + std::string a = *Red::GetStrArray(msg.c_str()); + std::cout << *Red::DecryptResECB1536(*Red::GetStrArray(msg), key); } std::cout << std::endl << std::endl << std::endl << "Press Enter to continue."; diff --git a/src/ResCBC1024.cpp b/src/ResCBC1024.cpp index 664bda4..74d9687 100644 --- a/src/ResCBC1024.cpp +++ b/src/ResCBC1024.cpp @@ -7,8 +7,8 @@ * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) */ -#include "ResCBC1024.h" -#include "_private/ResDeclarations.h" +#include "./ResCBC1024.h" +#include "./_private/ResDeclarations.h" using namespace Red::Res; @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/src/ResCBC1024.h b/src/ResCBC1024.h index 7adff22..6f0a607 100644 --- a/src/ResCBC1024.h +++ b/src/ResCBC1024.h @@ -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 @@ -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 diff --git a/src/ResCBC1536.cpp b/src/ResCBC1536.cpp index 3a9132a..2d33c44 100644 --- a/src/ResCBC1536.cpp +++ b/src/ResCBC1536.cpp @@ -7,8 +7,8 @@ * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) */ -#include "ResCBC1536.h" -#include "_private/ResDeclarations.h" +#include "./ResCBC1536.h" +#include "./_private/ResDeclarations.h" using namespace Red::Res; @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/src/ResCBC1536.h b/src/ResCBC1536.h index 487f95a..4eec2ec 100644 --- a/src/ResCBC1536.h +++ b/src/ResCBC1536.h @@ -1,5 +1,5 @@ /** - * @file ResCBC1526.h + * @file ResCBC1536.h * @brief Definition of Res CBC 1536 bits algorithm. * * Copyright (c) 2020-2021 Vladimir Rogozin (vladimir20040609@gmail.com) @@ -14,7 +14,7 @@ namespace Red { /** - * @brief EncryptCResBC1536 + * @brief EncryptResCBC1536 * * @param in String to encrypt * @param key Private key @@ -22,14 +22,14 @@ 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 ); /** - * @brief EncryptResCBC1536 + * @brief DecryptResCBC1536 * * @param in String to decrypt * @param key Private key @@ -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 diff --git a/src/ResCBC512.cpp b/src/ResCBC512.cpp index 55eda51..eae4a8a 100644 --- a/src/ResCBC512.cpp +++ b/src/ResCBC512.cpp @@ -7,8 +7,8 @@ * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) */ -#include "ResCBC512.h" -#include "_private/ResDeclarations.h" +#include "./ResCBC512.h" +#include "./_private/ResDeclarations.h" using namespace Red::Res; @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/src/ResCBC512.h b/src/ResCBC512.h index 785eebe..f8eadad 100644 --- a/src/ResCBC512.h +++ b/src/ResCBC512.h @@ -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 @@ -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 diff --git a/src/ResECB1024.cpp b/src/ResECB1024.cpp index 7df6121..d34427a 100644 --- a/src/ResECB1024.cpp +++ b/src/ResECB1024.cpp @@ -7,8 +7,8 @@ * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) */ -#include "ResECB1024.h" -#include "_private/ResDeclarations.h" +#include "./ResECB1024.h" +#include "./_private/ResDeclarations.h" using namespace Red::Res; @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/src/ResECB1024.h b/src/ResECB1024.h index 5178f69..82edcab 100644 --- a/src/ResECB1024.h +++ b/src/ResECB1024.h @@ -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 @@ -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 diff --git a/src/ResECB1536.cpp b/src/ResECB1536.cpp index 77339c7..d8edcf7 100644 --- a/src/ResECB1536.cpp +++ b/src/ResECB1536.cpp @@ -7,8 +7,8 @@ * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) */ -#include "ResECB1536.h" -#include "_private/ResDeclarations.h" +#include "./ResECB1536.h" +#include "./_private/ResDeclarations.h" using namespace Red::Res; @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/src/ResECB1536.h b/src/ResECB1536.h index 8015dc5..f0267b4 100644 --- a/src/ResECB1536.h +++ b/src/ResECB1536.h @@ -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 @@ -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 diff --git a/src/ResECB512.cpp b/src/ResECB512.cpp index 2114ead..5bb6d1f 100644 --- a/src/ResECB512.cpp +++ b/src/ResECB512.cpp @@ -7,8 +7,8 @@ * Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt * or copy at http://opensource.org/licenses/MIT) */ -#include "ResECB512.h" -#include "_private/ResDeclarations.h" +#include "./ResECB512.h" +#include "./_private/ResDeclarations.h" using namespace Red::Res; @@ -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(); @@ -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; @@ -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(); @@ -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; diff --git a/src/ResECB512.h b/src/ResECB512.h index b9ccbdd..4e1c827 100644 --- a/src/ResECB512.h +++ b/src/ResECB512.h @@ -22,7 +22,7 @@ namespace Red { * * @return Encrypted string */ - const std::string EncryptResECB512(const std::string& in, const std::string_view key); + std::string * EncryptResECB512(const std::string& in, const std::string_view key); /** * @brief EncryptResECB512 @@ -33,7 +33,7 @@ namespace Red { * * @return Decrypted string */ - const std::string DecryptResECB512(const std::string& in, const std::string_view key); + std::string * DecryptResECB512(const std::string& in, const std::string_view key); } #endif // RED_RESECB512_H