New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parsel

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parsel

  • 1.0.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

parsel

Code Climate Build Status Gem Gem

Encrypt and decrypt data with a given key.

This library was created to allow an easy data exchange between Ruby and Node.js.

Check it out the Node.js counter-part: http://github.com/fnando/parsel-js.

Installation

gem install parsel

Usage

require "parsel"

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.

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.

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}

Custom Cipher IV

Make sure you use a 16-chars long if you're going to exchange data with parsel-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:

Parsel.default_iv = SecureRandom.hex(100)

You can also pass the IV to encrypt/decrypt methods.

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

License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Package last updated on 06 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc