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