Skip to content

Commit

Permalink
README.md: use spaces for code
Browse files Browse the repository at this point in the history
  • Loading branch information
gewo committed Feb 27, 2017
1 parent 01cb7bc commit 1316a7e
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,44 @@
[![Build Status](https://travis-ci.org/gewo/hmac_auth.png)](https://travis-ci.org/gewo/hmac_auth/)
[![Code Coverage](https://coveralls.io/repos/gewo/hmac_auth/badge.png)](https://coveralls.io/r/gewo/hmac_auth)

```
__ ____ ______ _________ __ __
/ / / / |/ / | / ____/ | __ __/ /_/ /_
/ /_/ / /|_/ / /| |/ / / /| |/ / / / __/ __ \
/ __ / / / / ___ / /___/ ___ / /_/ / /_/ / / /
/_/ /_/_/ /_/_/ |_\____/_/ |_\__,_/\__/_/ /_/
__ ____ ______ _________ __ __
/ / / / |/ / | / ____/ | __ __/ /_/ /_
/ /_/ / /|_/ / /| |/ / / /| |/ / / / __/ __ \
/ __ / / / / ___ / /___/ ___ / /_/ / /_/ / / /
/_/ /_/_/ /_/_/ |_\____/_/ |_\__,_/\__/_/ /_/

```

Ruby gem providing HMAC based message signing and verification. Without
fancy Rails integration.

## Installation

```ruby
gem 'hmac_auth' # Gemfile
gem install hmac_auth # manual
```
gem 'hmac_auth' # Gemfile
gem install hmac_auth # manual

## Usage

```ruby
# Configuration
HMACAuth.secret = 't0p_s3cr3!!eins1'
HMACAuth.reject_keys = %w(action controller format)
HMACAuth.valid_for = 15.minutes
# Configuration
HMACAuth.secret = 't0p_s3cr3!!eins1'
HMACAuth.reject_keys = %w(action controller format)
HMACAuth.valid_for = 15.minutes

to_be_signed = {
b: 2,
a: { d: 4, c: 3 }
}
to_be_signed = {
b: 2,
a: { d: 4, c: 3 }
}

signed = HMACAuth::Signature.sign to_be_signed
# => Hash including 'timestamp' and 'signature'
signed = HMACAuth::Signature.sign to_be_signed
# => Hash including 'timestamp' and 'signature'

HMACAuth::Signature.verify(signed) # => true
HMACAuth::Signature.verify(signed.merge(evil: 'yes')) # => false
HMACAuth::Signature.verify(signed, secret: 'good guess?') # => false
HMACAuth::Signature.verify(signed) # => true
HMACAuth::Signature.verify(signed.merge(evil: 'yes')) # => false
HMACAuth::Signature.verify(signed, secret: 'good guess?') # => false

sleep 20.minutes
HMACAuth::Signature.verify(signed) # => false
sleep 20.minutes
HMACAuth::Signature.verify(signed) # => false

# That's it. Nothing more, nothing less.
```
# That's it. Nothing more, nothing less.

## Contributing

Expand Down

0 comments on commit 1316a7e

Please sign in to comment.