Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jackc/ruby-extid
https://github.com/jackc/ruby-extid
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jackc/ruby-extid
- Owner: jackc
- License: mit
- Created: 2022-10-26T19:53:35.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-26T20:08:44.000Z (about 2 years ago)
- Last Synced: 2024-10-07T21:07:32.199Z (30 days ago)
- Language: Ruby
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ExtID
It can be valuable to internally use a serial integer as an ID without revealing that ID to the outside world. extid
uses AES-128 to convert to and from an external ID that cannot feasibly be decoded without the secret key.This prevents outsiders from quantifying the usage of your application by observing the rate of increase of IDs as well
as provides protection against brute force crawling of all resources.## Installation
Install the gem and add to the application's Gemfile by executing:
```
$ bundle add extid
```If bundler is not being used to manage dependencies, install the gem by executing:
```
$ gem install extid
```## Usage
```ruby
require 'extid'prefix = "user"
key = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15].pack('C*')
type = ExtID::Type.new prefix, key
type.encode(1) # => "user_13189a6ae4ab07ae70a3aabd30be99de"
type.decode("user_13189a6ae4ab07ae70a3aabd30be99de") # => 1
```## Other Implementations
* [Go](https://github.com/jackc/go-extid)
* [PostgreSQL](https://github.com/jackc/pg-extid)