Git Product home page Git Product logo

ruby-easy-crypto's Introduction

EasyCrypto Build Status Gem Version

Provides simple wrappers around the openssl crypto implementation. The library provides two interfaces: simple and advanced. Simple mode is designed for ease-of-use and advanced mode provides some performance benefits in certain use-cases. See below for more details.

All the underlying crypto operations are the same.

Installation

Add this line to your application's Gemfile:

gem 'easy-crypto'

And then execute:

$ bundle

Or install it yourself as:

$ gem install easy-crypto

Simple usage (Recommended)

require 'easycrypto'

password = 'secret password'
plaintext = 'some data'

ecrypto = EasyCrypto::Crypto.new

encrypted = ecrypto.encrypt(password, plaintext)
decrypted = ecrypto.decrypt(password, encrypted)

decrypted == plaintext

Advanced usage (Use for performance)

Key derivation is a resource heavy process. The simple interface abstracts this away and forces you to recompute the key before each encryption/decryption process.

This interface allows you to cache the result of the key derivation. This is required if you need to encrypt/decrypt multiple times with the same derived key. Caching the key saves you the time to have to recompute it before every encryption/decryption.

require 'easycrypto'

password = 'secret password'
plaintext = 'data to encrypt ...'

ecrypto = EasyCrypto::Crypto.new

key = EasyCrypto::Key.generate(key_password)

encrypted = ecrypto.encrypt_with_key(key, plaintext)
decrypted = ecrypto.decrypt_with_key(key, encrypted)

decrypted == plaintext

License

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

ruby-easy-crypto's People

Contributors

dsztanko avatar knagy avatar mihdavid avatar szeist avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.