Project

epithet

0.0
The project is in a healthy, maintained state
Epithet generates stable, prefixed, Base58 identifiers from 64-bit integers using AES and HMAC.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
>= 7
 Project Readme

Epithet

Epithet generates stable, compact, purposefully prefixed Base58 identifiers from 64-bit integers for reversible obfuscation and tamper detection.

Installation

Add to your Gemfile:

gem 'epithet'

Or install directly:

gem install epithet

Usage

require 'epithet'

def epithet_initialize
  Epithet.configure(
    passphrase: ENV.fetch('EPITHET_PASSPHRASE') { 'example only' },
    salt: 'v1'
  )
end

epithet_initialize
user_epithet = Epithet.new('user')

id = 42
param = user_epithet.encode(id)
# => "user_VsuNnfEYQJJTJYE3n28jaY"

user_epithet.decode(param)
# => 42

Configuration at initialisation is recommended, because deriving key material from the passphrase uses scrypt, and is consequently expensive. The salt: is optional; it's included when deriving the subkey material for obfuscating and tamper resistance, and may be useful for additional context discrimination or during secrets rotation.

Refer to the Epithet rdoc for the full set of configuration options.

Note that decode returns nil when authentication fails and raises ArgumentError on invalid formats.

Development

Install dependencies and run tests:

bundle install
rake test

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/inopinatus/epithet.

Security considerations

See SECURITY.md.

License

The gem is available as open source under the terms of the MIT License.