Skip to content

Yinfei/simple_rsa

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleRSA

Just an RSA interface. It's based on https://nunojob.wordpress.com/2008/12/08/rsa-encrypt-decrypt-in-ruby/ works.

Installation

Add this line to your application's Gemfile:

gem 'simple_rsa', git: 'https://github.com/digitalfibr/simple_rsa.git'

And then execute:

$ bundle

Usage

Generate your keys

  SimpleRSA.generate_keys_in "./tmp"
  #will generate public and private keys in tmp folder

Filesystem keys

  rsa = SimpleRSA::FileSystem.new './tmp'
  # generates tmp/id_rsa and tmp/id_rsa.pub
  
  encrypted = rsa.encrypt 'Hello secret world'
  # retour your rsa encrypted string : "aIwGJgP9Wo/ZMgXS4m...8nfH1aviqAsf37u4=\n"
  
  rsa.decrypt encrypted
  # retour your rsa decrypted string : "Hello secret world"

Env keys

Heroku for instance does not allow to store files and you don't want to drop you keys in our sources. So you will use env to store them

https://stackoverflow.com/questions/6942600/multi-line-config-variables-in-heroku

  heroku config:add SIMPLE_ID_RSA="YOUR_ID_RSA" SIMPLE_ID_RSA_PUB="YOUR_ID_RSA_PUB"
  rsa = SimpleRSA::Environment.new
  
  # or if you want to change prefix
  
  rsa = SimpleRSA::Environment.new "MY"
  # will load MY_ID_RSA and MY_ID_RSA_PUB

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%