#pragma once #include #include // Ensure this is the version with 'bytes password_hash' #include // Required for std::function // This struct definition is correct and necessary. struct UserData { char username[33]; // 32 chars + null terminator uint8_t password_hash[32]; // 32-byte raw SHA-256 hash }; class Users { public: Users(); ~Users(); bool addUser(const char* username, const char* password); bool deleteUser(const char* username); bool updatePassword(const char* username, const char* newPassword); bool userExists(const char* username) const; bool checkPassword(const char* username, const char* password) const; bool loadUsernamesCallback(const std::function& callback) const; size_t getUserCount(); void reset(); private: const char* filename_ = "/users.pb"; static constexpr size_t MAX_USERS = 5; mutable size_t userCount_ = 0; mutable bool initialized_ = false; void hashPassword(const char* password, uint8_t* hash_out) const; static bool _iterateUsers(const char* filename, const std::function& user_callback); static bool _transformUsers(const char* src_filename, const std::function& transform_callback); }; extern Users users;