An Elixir library for obfuscating numerical IDs into short, unique, reversible strings.
Hashids is an Elixir library that obfuscates numerical identifiers by encoding them into short, unique, reversible strings. It solves the problem of exposing sequential database IDs in user-facing contexts like URLs or APIs, providing a simple way to create non-sequential, customizable identifiers. The library is a direct port of the popular Hashids JavaScript implementation, adapted for Elixir's functional programming environment.
Elixir developers building web applications, APIs, or services where hiding sequential database IDs improves user experience or perceived security.
Developers choose Hashids for its simplicity, reversibility, and customization options—offering a lightweight alternative to cryptographic hashing when security isn't the primary concern, with easy integration into Elixir projects.
Stringify your ids
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Converts lists of integers into short, unique strings that can be accurately decoded back, as shown with examples like encoding [1,2,3,4] to '4bSwImsd' and decoding to the original list.
Supports custom salts, minimum output lengths, and alphabets, allowing tailored encoding for different use cases, such as using a Cyrillic alphabet for specialized tokens in the MyAccessToken example.
Direct implementation of the popular Hashids JavaScript library, ensuring proven functionality and ease of adoption for Elixir developers, with consistent behavior across ecosystems.
Enables custom character sets with a minimum of 16 characters, facilitating unique encoding schemes without being restricted to default alphanumeric strings.
Explicitly not designed for security, making it vulnerable to reverse engineering or attacks if used for protecting sensitive information, as admitted in the philosophy section.
Version 2.0 introduced migration requirements from 1.0, as noted in the changelog reference, which can disrupt existing implementations and require additional effort to update.
Limited to encoding lists of integers, so preprocessing is needed for other data types like strings or floats, adding complexity for non-numeric use cases.