Skip to content

Commit

Permalink
Better explain algorithm used for hash in generateCacheString
Browse files Browse the repository at this point in the history
  • Loading branch information
stuarthayhurst committed Sep 9, 2024
1 parent 1d709e6 commit 56d586d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ammonite/core/fileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,20 @@ namespace ammonite {
}

namespace {
//Don't use this for security, you'll lose your job
/*
- Hash together fileCount paths from filePaths
- Don't use this for security, you'll lose your job
*/
static std::string generateCacheString(std::string* filePaths,
unsigned int fileCount) {
alignas(uint64_t) uint8_t output[8] = {0};
uint8_t prev = 0;

/*
- XOR the first byte of the hash with each character of each path
- After each character, sequentially XOR every byte of the hash with the result of
the previous XOR
- XOR the first byte of the hash with the first character of the first path
- Sequentially XOR every byte of the hash with the result of the previous
operation of this stage
- Repeat this process for every character of every path
*/
for (unsigned int i = 0; i < fileCount; i++) {
uint8_t* filePath = (uint8_t*)filePaths[i].c_str();
Expand Down

0 comments on commit 56d586d

Please sign in to comment.