You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
450 B

4 years ago
  1. #include <string>
  2. #include <sstream>
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <stdlib.h>
  6. #include "utils.h"
  7. std::string int_to_hex( u64 i )
  8. {
  9. std::stringstream stream;
  10. stream << "0x"
  11. << std::setfill ('0') << std::setw(16)
  12. << std::hex << i;
  13. return stream.str();
  14. }
  15. u64 fnv1a(std::string s) {
  16. u64 hash = 0xCBF29CE484222325LL;
  17. for(char& c : s) {
  18. hash ^= u64(c);
  19. hash *= 0x100000001B3LL;
  20. }
  21. return hash;
  22. }