// Sigue FNV-1a byte por byte: un cambio en un byte afecta a todos los que vienen después.
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <string>

void trace(const std::string& key) {
    std::uint64_t hash = 14695981039346656037ULL;
    std::cout << "clave \"" << key << "\"\n" << std::hex << std::setfill('0');
    std::cout << "  inicio        " << std::setw(16) << hash << "\n";
    for (char c : key) {
        hash ^= static_cast<unsigned char>(c);
        std::cout << "  xor  " << std::setw(2) << static_cast<int>(static_cast<unsigned char>(c))
                  << "       " << std::setw(16) << hash << "\n";
        hash *= 1099511628211ULL;
        std::cout << "  por el primo  " << std::setw(16) << hash << "\n";
    }
    std::cout << std::dec << std::setfill(' ');
}

int main() {
    trace("ab");
    trace("ba");
}
