0.0
No commit activity in last 3 years
No release in over 3 years
JWT-like solution, that enables you to store encrypted and signed Hash'es on the client side, decrypt and verify them upon retreival
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.5
>= 0

Runtime

 Project Readme

SecureToken

Gem that provides JWT token like solution. You can convert any hash into a string that is suitable for storage at the client-side. It is URL-safe, encrypted and digitally signed.

Installation

Add this line to your application's Gemfile:

gem 'secure_token'

And then execute:

$ bundle

Or install it yourself as:

$ gem install secure_token

Usage

    require 'secure_token'

    data = SecureToken::SecureTokenHash.new

    data.merge!({
      key: 'value',
      another: {
        place: 1,
        subdata: [ 4, 5, 6 ]
      }
    })

    key = SecureToken::KeyPair.new('s3cret', 'service')

    encrypted = data.to_token(key)
    # encrypted is url-safe
    # looks like "0qaai-mRZZY0WMJci13QST11UI80NiSc9YXb4ABW-pgauFH2wDtDpbH7Vm408BOP5xlq2jO3Srz_WqDlehi1AYP3VtFoUdtNtjuvObess0Lh35Yml1opZ2QOlJ2brwmjNxNWsEoC6JMsdzMUSuF-1JrQwvarPC5B"

    decrypted = SecureToken::SecureTokenHash.from_token(encrypted, key)
    # assert(decrypted == data)

    invalid_key = SecureToken::KeyPair.new('secret', 'serv1ce')
    not_decrypted = SecureToken::SecureTokenHash.from_token(encrypted, invalid_key)
    # assert(not_decrypted == nil)

Contributing

  1. Fork it ( http://github.com/skywriter/secure_token/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request