mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 00:22:14 +11:00
🐛 hash deterministic
This commit is contained in:
parent
068ef5e136
commit
e4b6d2987d
2 changed files with 7 additions and 7 deletions
|
|
@ -54,7 +54,7 @@ public:
|
|||
bool DelUser(const std::string &name, const std::string &attempt)
|
||||
{
|
||||
std::unique_lock<std::shared_mutex> lock{size_lock};
|
||||
return users.erase_if(name, [&attempt](const User &u) { return (XXH64(attempt.data(), attempt.size(), 0) == u.password); });
|
||||
return users.erase_if(name, [&attempt](const User &u) { return (XXH64(attempt.data(), attempt.size(), 1) == u.password); });
|
||||
}
|
||||
bool AdminDelUser(const std::string &name, const std::string &attempt)
|
||||
{
|
||||
|
|
@ -75,7 +75,7 @@ public:
|
|||
bool state = false;
|
||||
std::shared_lock<std::shared_mutex> lock{send_funds_l}; //because SendFunds requires 3 locking operations
|
||||
users.modify_if(a_name, [&state, amount, &attempt](User &a) {
|
||||
if (state = (a.balance >= amount) && (a.password == XXH64(attempt.data(), attempt.size(), 0)))
|
||||
if (state = (a.balance >= amount) && (a.password == XXH64(attempt.data(), attempt.size(), 1)))
|
||||
{
|
||||
a.balance -= amount;
|
||||
}
|
||||
|
|
@ -126,7 +126,7 @@ public:
|
|||
{
|
||||
int_fast8_t res = -1;
|
||||
users.if_contains(name, [&res, &attempt](const User &u) {
|
||||
res = u.password == XXH64(attempt.data(), attempt.size(), 0);
|
||||
res = u.password == XXH64(attempt.data(), attempt.size(), 1);
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
|
@ -134,10 +134,10 @@ public:
|
|||
{
|
||||
int_fast8_t res = -1;
|
||||
users.modify_if(name, [&res, &attempt, &new_pass](User &u) {
|
||||
res = (u.password == XXH64(attempt.data(), attempt.size(), 0));
|
||||
res = (u.password == XXH64(attempt.data(), attempt.size(), 1));
|
||||
if (res)
|
||||
{
|
||||
u.password = XXH64(new_pass.data(), new_pass.size(), 0);
|
||||
u.password = XXH64(new_pass.data(), new_pass.size(), 1);
|
||||
}
|
||||
});
|
||||
return res;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct User
|
|||
*
|
||||
* @param init_pass initial password
|
||||
*/
|
||||
User(std::string &&init_pass) : password(XXH64(init_pass.data(), init_pass.size(), 0)) {}
|
||||
User(std::string &&init_pass) : password(XXH64(init_pass.data(), init_pass.size(), 1)) {}
|
||||
|
||||
/**
|
||||
* @brief User Constructor for admins
|
||||
|
|
@ -20,7 +20,7 @@ struct User
|
|||
* @param init_bal initial balance
|
||||
* @param init_pass initial password
|
||||
*/
|
||||
User(uint_fast32_t init_bal, std::string &&init_pass) : balance(init_bal), password(XXH64(init_pass.data(), init_pass.size(), 0)) {}
|
||||
User(uint_fast32_t init_bal, std::string &&init_pass) : balance(init_bal), password(XXH64(init_pass.data(), init_pass.size(), 1)) {}
|
||||
|
||||
Json::Value Serialize() const
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue