SecretKey
Ruby Gem for generating a unique access token when provided with an application id, application secret and timestamp
Installation
Add this line to your application's Gemfile:
gem 'secretkey'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install secretkey
Usage
To generate a token, simply run this method:
secretkey = SecretKey::SecretKey.new(key, secret)
token = secretkey.token
SecretKey will automatically generate a timestamp, which can be accessed by running:
secretkey.timestamp
Alternatively, you can specify your own timestamp:
timestamp = Time.now.to_i
secretkey = SecretKey::SecretKey.new(key, secret, timestamp: timestamp)
token = secretkey.token
Where:
-
key
- application key -
secret
- application secret -
timestamp
- an epoch timestamp in seconds i.e. 2014-07-24 14:03:30 +1000 would be 1406174610 in epoch format
Style guidelines
We try to adhere to the following coding style guidelines
- https://github.com/styleguide/ruby
- https://github.com/bbatsov/rails-style-guide
- https://github.com/bbatsov/ruby-style-guide
Contributing
- Fork it ( http://github.com/jobready/secretkey/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request