No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A C++11 port of the Python hashids implementation. It generates Youtube-like hashes from one or many numbers. Use hashids when you do not want to expose your database ids to the user. Website:

The library itself is a single header, single source file. This library requires C++11 to compile, but you can include it and link against it perfectly fine with C++98. You'll just miss certain C++11 features like the initializer_list encode method, the move constructor, etc.

Basic usage

To encode a single integer

  hashidsxx::Hashids hash;
  std::cout << hash.encode({123}) << std::endl; // 'Mj3'

To decode a hash:

  hashidsxx::Hashids hash;
  std::vector<uint64_t> output = hash.decode("Mj3");
  for (uin64_t h : output) std::cout << h << std::endl; // 123

Custom salts, alphabets and minimum lengths are passed into the constructor of Hashids

  hashidsxx::Hashids hash("salt", 16, "abcdefghijklmnopqrstuvwxyz");
  std::cout << hash.encode({123456789}) << std::endl; // Prints oavlpogkzrxrkpxd