Skip to content

Commit

Permalink
Use sha256 and std::string instead of BinaryToHex, hopefully will fix…
Browse files Browse the repository at this point in the history
… weird client side hashing errors
  • Loading branch information
TheROPFather committed Jul 22, 2018
1 parent 5def426 commit 98070cc
Show file tree
Hide file tree
Showing 3 changed files with 385 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/CMakeData-globals.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ list(APPEND SMDATA_GLOBAL_FILES_HPP
"SpecialFiles.h"
"StdString.h" # TODO: Remove the need for this file, transition to std::string.
"StepMania.h" # TODO: Refactor into separate main project.
"picosha2.h"
)

source_group("Global Files" FILES ${SMDATA_GLOBAL_FILES_SRC} ${SMDATA_GLOBAL_FILES_HPP})
9 changes: 7 additions & 2 deletions src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Foreach.h"
#include "GameConstantsAndTypes.h"
#include "HighScore.h"
#include "picosha2.h"
#include "PlayerNumber.h"
#include "ProfileManager.h"
#include "RadarValues.h"
Expand Down Expand Up @@ -846,7 +847,7 @@ bool HighScore::IsEmpty() const
}

string HighScore::GenerateValidationKeys() {
string key = "";
std::string key = "";

FOREACH_ENUM(TapNoteScore, tns) {

Expand Down Expand Up @@ -878,7 +879,11 @@ string HighScore::GenerateValidationKeys() {
key.append(to_string(static_cast<int>(GetEtternaValid())));
key.append(GradeToString(GetWifeGrade()));

SetValidationKey(ValidationKey_Brittle, BinaryToHex(CryptManager::GetSHA1ForString(key)));
std::string hash_hex_str;

picosha2::hash256_hex_string(key, hash_hex_str);

SetValidationKey(ValidationKey_Brittle, hash_hex_str);

// just testing stuff
//hs.SetValidationKey(ValidationKey_Weak, GenerateWeakValidationKey(m_iTapNoteScores, m_iHoldNoteScores));
Expand Down
Loading

0 comments on commit 98070cc

Please sign in to comment.