No commit activity in last 3 years
No release in over 3 years
The easiest way to encrypt your carrierwave files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0

Runtime

~> 1.4.0
 Project Readme

CarrierWave::EasyEncryption

The easiest way to encrypt files uploaded to Rails when you're storing with CarrierWave.

Based on carrierwave_securefile, but simpler.

Tested with Ruby 2 and Rails 4.

Installation

Add this line to your application's Gemfile:

gem 'carrerwave_easy_encryption'

And then execute:

$ bundle

Or install it yourself as:

$ gem install carrerwave_easy_encryption

Usage

###Add an initializer###

CarrierWave::EasyEncryption.configure do |config|
  config.password = "<some long hex digits, e.g. the output of SecureRandom.hex(32)>"
end`

###Modify the uploaders you want to encrypt###

class MyUploader < CarrierWave::Uploader::Base
  process :encrypt

  def encrypt
    CarrierWave::EasyEncryption::Uploader.secure_file(model, self.file.path.to_s)
  end
end

###Add controller actions for decrypting files before downloading###

def download
  @model = Model.find(params(:id))
  send_data CarrierWave::EasyEncryption::Downloader.download(@model.my_uploader).string, filename: File.basename(@model.my_uploader.path)
end

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