README.md in parsel-0.1.1 vs README.md in parsel-0.2.0

- old
+ new

@@ -11,14 +11,44 @@ gem install parsel ## Usage - require "parsel" +```ruby +require 'parsel' - secret_key = "mysupersecretkeythatnobodyknowsabout" - encrypted = Parsel.encrypt(secret_key, "hello from ruby!") - decrypted = Parsel.decrypt(secret_key, encrypted) +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' + +data = {user_id: 1234} + +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' + +data = {user_id: 1234} + +secret_key = 'mysupersecretkeythatnobodyknowsabout' +encrypted = Parsel::JSON.encrypt(secret_key, data) + +decrypted = Parsel::JSON.decrypt(secret_key, encrypted) +#=> {"user_id" => 1234} +``` ## Maintainer - Nando Vieira (<http://nandovieira.com.br>)