README.md in parsel-0.3.0 vs README.md in parsel-1.0.0

- old
+ new

@@ -1,7 +1,12 @@ # parsel +[![Code Climate](https://codeclimate.com/github/fnando/parsel-rb.png)](https://codeclimate.com/github/fnando/parsel-rb) +[![Build Status](https://travis-ci.org/fnando/parsel-rb.svg)](https://travis-ci.org/fnando/parsel-rb) +[![Gem](https://img.shields.io/gem/v/parsel.svg)](https://rubygems.org/gems/parsel) +[![Gem](https://img.shields.io/gem/dt/parsel.svg)](https://rubygems.org/gems/parsel) + Encrypt and decrypt data with a given key. This library was created to allow an easy data exchange between Ruby and Node.js. @@ -12,47 +17,49 @@ gem install parsel ## Usage ```ruby -require 'parsel' +require "parsel" -secret_key = 'mysupersecretkeythatnobodyknowsabout' -encrypted = Parsel.encrypt(secret_key, 'hello from ruby!') +secret_key = "mysupersecretkeythatnobodyknowsabout" +encrypted = Parsel.encrypt(secret_key, "hello from ruby!") decrypted = Parsel.decrypt(secret_key, encrypted) ``` You can also use Marshal for encrypting/decrypting objects. Notice that this isn't supported by Node.js. ```ruby -require 'parsel' +require "parsel" data = {user_id: 1234} -secret_key = 'mysupersecretkeythatnobodyknowsabout' +secret_key = "mysupersecretkeythatnobodyknowsabout" encrypted = Parsel::Marshal.encrypt(secret_key, data) decrypted = Parsel::Marshal.decrypt(secret_key, encrypted) #=> {user_id: 1234} ``` Alternatively you can use `JSON` as your serializer. ```ruby -require 'parsel' +require "parsel" data = {user_id: 1234} -secret_key = 'mysupersecretkeythatnobodyknowsabout' +secret_key = "mysupersecretkeythatnobodyknowsabout" encrypted = Parsel::JSON.encrypt(secret_key, data) decrypted = Parsel::JSON.decrypt(secret_key, encrypted) #=> {"user_id" => 1234} ``` ### Custom Cipher IV +![Make sure you use a 16-chars long if you're going to exchange data with parsel-js.](http://messages.hellobits.com/warning.svg?message=Make%20sure%20you%20use%20a%2016-chars%20long%20if%20you're%20going%20to%20exchange%20data%20with%20parsel-js.) + By default, this library uses a built-in IV. You may want to change that. You can globally change the IV like the following: ```ruby @@ -63,9 +70,11 @@ ```ruby Parsel.encrypt(secret_key, iv, data) Parsel.decrypt(secret_key, iv, data) ``` + +**NOTE:** If you're going to use <http://github.com/fnando/parsel-js> to exchange data, you have to use a 16-chars long IV. Node.js will fail with different lengths. ## Maintainer - Nando Vieira (<http://nandovieira.com.br>)