All Projects → mguymon → Paseto.rb

mguymon / Paseto.rb

Licence: mit
Ruby implementation of Paseto using libsodium.

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Paseto.rb

sodium
An wrapper for libsodium in golang
Stars: ✭ 54 (+31.71%)
Mutual labels:  libsodium
Sigmavpn
Light-weight, secure and modular VPN solution which makes use of NaCl encryption (also available for Android using jnacl in "sigmavpn-android")
Stars: ✭ 531 (+1195.12%)
Mutual labels:  libsodium
Halite
High-level cryptography interface powered by libsodium
Stars: ✭ 933 (+2175.61%)
Mutual labels:  libsodium
vtun
A mirror of VTUN, with some changes
Stars: ✭ 56 (+36.59%)
Mutual labels:  libsodium
Airship
Secure Content Management for the Modern Web - "The sky is only the beginning"
Stars: ✭ 422 (+929.27%)
Mutual labels:  libsodium
Libsodium.js
libsodium compiled to Webassembly and pure JavaScript, with convenient wrappers.
Stars: ✭ 665 (+1521.95%)
Mutual labels:  libsodium
libsodium-sys-stable
Sodiumoxide's libsodium-sys crate, but that installs stable versions of libsodium.
Stars: ✭ 16 (-60.98%)
Mutual labels:  libsodium
Nim Libsodium
Nim wrapper for the libsodium library
Stars: ✭ 32 (-21.95%)
Mutual labels:  libsodium
Libsodium Php
The PHP extension for libsodium.
Stars: ✭ 507 (+1136.59%)
Mutual labels:  libsodium
Globaleaks
GlobaLeaks is free, open source software enabling anyone to easily set up and maintain a secure whistleblowing platform.
Stars: ✭ 832 (+1929.27%)
Mutual labels:  libsodium
Sapient
Secure API Toolkit
Stars: ✭ 308 (+651.22%)
Mutual labels:  libsodium
Swift Sodium
Safe and easy to use crypto for iOS and macOS
Stars: ✭ 400 (+875.61%)
Mutual labels:  libsodium
Sodium compat
Pure PHP polyfill for ext/sodium
Stars: ✭ 736 (+1695.12%)
Mutual labels:  libsodium
libopaque
c implementation of the OPAQUE protocol with bindings for python, php, ruby, lua, zig, java, erlang, golang and js.
Stars: ✭ 30 (-26.83%)
Mutual labels:  libsodium
Lockbox
Modern encryption for Ruby and Rails
Stars: ✭ 905 (+2107.32%)
Mutual labels:  libsodium
libsodium-xchacha20-siv
Deterministic/nonce-reuse resistant authenticated encryption scheme using XChaCha20, implemented on libsodium.
Stars: ✭ 25 (-39.02%)
Mutual labels:  libsodium
Sodiumoxide
Sodium Oxide: Fast cryptographic library for Rust (bindings to libsodium)
Stars: ✭ 596 (+1353.66%)
Mutual labels:  libsodium
Wire Webapp
👽 Wire for web
Stars: ✭ 982 (+2295.12%)
Mutual labels:  libsodium
Rbnacl
Ruby FFI binding to the Networking and Cryptography (NaCl) library (a.k.a. libsodium)
Stars: ✭ 910 (+2119.51%)
Mutual labels:  libsodium
Pynacl
Python binding to the Networking and Cryptography (NaCl) library
Stars: ✭ 761 (+1756.1%)
Mutual labels:  libsodium

Paseto

Ruby implementation of Paseto using libsodium that currently only supports Version 2.

Paseto (Platform-Agnostic SEcurity TOkens) is a specification for secure stateless tokens.

Installation

To use Paseto, you will need to install libsodium (at least version 1.0.12 is required). See Installing libsodium for installation instructions.

Add this line to your application's Gemfile:

gem 'paseto'

And then execute:

$ bundle

Or install it yourself as:

$ gem install paseto

Usage

For all examples:

require 'paseto'

Signing Plaintext Public Messages

Public = Paseto::V2::Public
key = Public::SecretKey.generate
token = key.sign('too many secrets')

saved_key = key.public_key.encode64 # you can save this string to a db
decoded_key = Public::PublicKey.decode64(saved_key)
decoded_key.verify(token) # => 'too many secrets'

Encrypting Messages with a Shared Secret

Key = Paseto::V2::Local::Key
key = Key.generate
token = key.encrypt('a fancy message')

saved_key = key.encode64 # a base64 string representation of the key
decoded_key = Key.decode64(saved_key)
decoded_key.decrypt(token) # => 'a fancy message'

Using the Message Footer

The message footer is transmitted plaintext, and can be used for key lookup. Note that you still must always verify the token via #decrypt, or #verify, as this also verifies the integrity of the footer:

Local = Paseto::V2::Local
token = Paseto.parse(raw_data)
# NOTE: this has not yet been verified! You will always want to call
# .decrypt or .verify *immediately* after using this value. Otherwise, you
# will be using data that has not been authenticated.
kid = token.footer

saved_key = database.find_key(kid) # find the previously stored key
decoded_key = Local::Key.decode64(saved_key)
decoded_key.decrypt(token) # => 'too many secrets'

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/paseto. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Paseto project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].