Socket
Book a DemoInstallSign in
Socket

active_uxid

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

active_uxid

5.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

ActiveUxid

Gem Version Build Status

ActiveUxid is a library for generating obfuscated UXid's.

Installation

Add this line to your application's Gemfile:

gem 'active_uxid'

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_uxid

Table of Contents

Configuration

rails generate active_uxid:install will generate the following file: ../config/initalizers/active_uxid.rb

ActiveUxid.configure do |config|
  config.encoding_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
  config.encoding_length = 26
  config.encoding_salt = 1_369_136
end

Hash

# Hash ID's are reversible but less performant
# than ULID

ActiveUxid::Hash.encode(10)         #=> 'q5D8inm0'
ActiveUxid::Hash.decode('q5D8inm0') #=> 10

Ulid

# ULID are secure as they are not reversible
# They are also more performant than Hash ID's

ActiveUxid::Ulid.encode #=> '1mqfg9qa96s8s5f02o1ucf8lcc'

ActiveRecord

class User < ActiveRecord::Base
  # Add a uxid binary attribute to the corresponding table.

  include ActiveUxid::Record::Hash
  # Or
  include ActiveUxid::Record::Ulid
end

# Hash UXid's type only
User.find_by_uxid('x123') #=> find record by uxid

user = User.new
user.uxid_to_id          #=> decodes the records uxid to id

Contributing

Your contribution is welcome.

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Added some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 12 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.