Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BfCrypt.cpp #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Update BfCrypt.cpp #2

wants to merge 3 commits into from

Conversation

Seltraeh
Copy link

@Seltraeh Seltraeh commented Oct 6, 2024

Cleaning up code using namespace.

I'm not going to go through an update everything like this. I'm just testing the waters first while I continue to learn C++.

I know the implications of obfuscating too much, but thought it easier to read the code and gave me a good entry point into understanding what you are achieving in the BFCrypt.cpp file.

Could you let me know on discord if something looks off in what I did?

Cleaning up code using namespace
I needed to add additional namespace reductions from the other night
Updated the namespace using comments
@@ -13,7 +13,7 @@ using namespace CryptoPP; // for aes, modes, and filters
static const unsigned char SREE_KEY[] = { 0x37, 0x34, 0x31, 0x30, 0x39, 0x35, 0x38, 0x31, 0x36, 0x34, 0x33, 0x35, 0x34, 0x38, 0x37, 0x31 }; // 7410958164354871
static const unsigned char SREE_IV[] = { 0x42, 0x66, 0x77, 0x34, 0x65, 0x6E, 0x63, 0x72, 0x79, 0x70, 0x65, 0x64, 0x50, 0x61, 0x73, 0x73 }; // Bfw4encrypedPass

std::string BfCrypt::CryptSREE(const Json::Value& v)
string CryptSREE(const Json::Value& v)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think automatilly setting the namespace for CryptSREE would make the function think it's not part of a class rather part of function outside of any namespace

@@ -61,13 +59,13 @@ std::string BfCrypt::CryptGME(const Json::Value& v, const std::string& key)
byte aeskey[AES::MIN_KEYLENGTH] = { 0x00 };
// keys are setted this way because we know that some keys might not have the minimum requirement
#ifdef _MSC_VER
memcpy_s(aeskey, _countof(aeskey), key.data(), std::min(key.size(), (size_t)sizeof(aeskey)));
memcpy_s(aeskey, _countof(aeskey), key.data(), min(key.size(), (size_t)sizeof(aeskey)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember a compilation error might happend on Windows unless NOMINMAX is defined, is this code buildable with MSVC + Windows?

#include <drogon/utils/Utilities.h>

using namespace std;
using namespace BfCrypt; // for CryptGME and DecryptGME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the BfCrypt:: removal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants