carrierwave_encrypter_decrypter 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2NiYjhkNDYyZWUzZmM3ZTdmMzZhZjkwNTdjMzI1MjVmNmE1NTg1MQ==
4
+ YzRiMGRjOWZkZjUyNzBiOTY2MTVlNjhkMDRlYWRmYjUzYmQ2M2ZmYQ==
5
5
  data.tar.gz: !binary |-
6
- NDRlMzQxMmUyZjNhMGE1ZDg1MzFmZjFmNmYxMDA1YmQ3OGVjODAxNQ==
6
+ NDJjZWYzYzM4ZDE4MGRjZGQ4YmNhNjQ1ODM4MDYxMGJkMTEzZDFhZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjAzNDc5ZmJlZGI0YWY0YTk4YzM5MzY1ZTE1MmM1NTVhMmI0Yzg2MzhiZjMy
10
- OGE1YmZlYjAxZDE0MGIyZTk1NTA4YTZmM2MxMWUyMjQ0ZjBiZjRhNGRhY2Ux
11
- OTM1N2IwOGU1NmQ2OWYxZDg4MTZiODY4OTE0ZjM4OTAyNWM1YWU=
9
+ YzA0OTU4NGZiOWZlMzFjMGM2ZGE4NWQ2ODg1OWExNmRiODM1Mzg5M2M0YjI1
10
+ YTQ1YWE1NWQ2YmRiZjNjMWIwNjRjZDhmYzVlODFhMjI3YjI4OWEwMzJiZmFk
11
+ ZWE5MDUyNWQ3YjIwMDE2Y2U1NmIxNzNkMGNkMjA2YzFhNzNiN2I=
12
12
  data.tar.gz: !binary |-
13
- MDUxY2MwZGZhYjYxMGUyZTI1MWEzZjdiZmRjMWVjM2MyZGY1N2YxNGY5MGRk
14
- MTY0YWJhMjFiZmE0YTM0ZjdhZTc5NDk5OTNlMTExMTI5OWQ3YTgwMjllYTZl
15
- Y2YzMThmMzNlMzRjNWIyYjQyYjVhNjM3ZGU2YTk2YWQ4Yzc5Yzg=
13
+ ODVkMWQ1OWViZWFhNDRkZjRhNTQ0YjI0NDZmYzczNTQ5NTJlMDE3OWQzMTRj
14
+ M2IxMDNiMjM5NTYwZWUyMDZjNjA0NGExNjVlZmI4NDVhYjkzZDJhYzk3NzIw
15
+ NGVkODk4ZDM5NTY3ZGY1MzJkN2RhY2FiZWY5Y2QwMjdjOGE2NTc=
@@ -0,0 +1,81 @@
1
+ **Note:** Gem Work in progress :pray: will be completed by 31st Dec 2013
2
+
3
+ # Carrierwave Encrypter Decrypter
4
+
5
+ A Rubygem to secure the file uploaded by encrypting the data and decryption on the fly. Completely secure and depends on Ruby 2.0.0 OpenSSL::Cipher and OpenSSL::PKCS5
6
+
7
+
8
+
9
+ ## Installation
10
+
11
+ Add the gem to the Gemfile:
12
+
13
+ gem "carrierwave_encrypter_decrypter"
14
+
15
+ bundle install
16
+
17
+ ## Getting Started
18
+
19
+ Start off by trigerring the installer
20
+
21
+ rails g ced:install
22
+
23
+
24
+ This will create a initializer `carrierwave_encrypter_decrypter`
25
+
26
+ create config/initializers/carrierwave_encrypter_decrypter.rb
27
+
28
+
29
+ Now in your Uploader for eg `app/uploaders/avatar_uploader.rb` add the after store callback
30
+
31
+
32
+ class AvatarUploader < CarrierWave::Uploader::Base
33
+ after :store, :encrypt_file
34
+
35
+ def encrypt_file(file)
36
+ Carrierwave::EncrypterDecrypter::Uploader.encrypt(self)
37
+ end
38
+ end
39
+
40
+ Now create the migration on the model on which your uploader is mounted
41
+
42
+ rails g migration add_iv_and_key_to_users iv:binary key:binary
43
+ rake db:migrate
44
+
45
+ **File Encryption**
46
+
47
+ The File encryption will happen with `Carrierwave::EncrypterDecrypter::Uploader.encrypt(self)` once the file is uploaded you will find it with a extendion of `.enc`
48
+
49
+
50
+ **File Decryption**
51
+
52
+
53
+ The File Decryption will happen with
54
+
55
+ Carrierwave::EncrypterDecrypter::Downloader.decrypt(model,mounted_as: :avatar)
56
+
57
+ Where `Model` is the model on which the uploader is mounted. The Encrypted file will be decrypted in the same folder.
58
+
59
+ Eg Controller
60
+
61
+ def download
62
+ #This will decryt the file first
63
+
64
+ Carrierwave::EncrypterDecrypter::Downloader.decrypt(@user,mounted_as: :avatar)
65
+
66
+ file_path = @user.avatar.path
67
+ File.open(file_path, 'r') do |f|
68
+ send_data f.read, type: MIME::Types.type_for(file_path).first.content_type,disposition: :inline,:filename => File.basename(file_path)
69
+ end
70
+ #This is to remove the decrypted file after transfer
71
+ File.unlink(file_path)
72
+ end
73
+
74
+
75
+
76
+ ## Licensing
77
+
78
+
79
+ The gem itself is released under the MIT license
80
+
81
+ :pray:
@@ -1,3 +1,3 @@
1
1
  module CarrierwaveEncrypterDecrypter
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators/named_base'
2
+
3
+ module Ced
4
+ module Generators
5
+ class Base < ::Rails::Generators::NamedBase
6
+ def self.source_root
7
+ @_ced_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'ced', generator_name, 'templates'))
8
+ end
9
+
10
+ if ::Rails::VERSION::STRING < '3.1'
11
+ def module_namespacing
12
+ yield if block_given?
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
@@ -0,0 +1,19 @@
1
+ module Ced
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ desc "This generator creates an initializer file at config/initializers"
5
+ def create_initializer_file
6
+ create_file "config/initializers/carrierwave_encrypter_decrypter.rb" do
7
+ "Carrierwave::EncrypterDecrypter.configure do |config|
8
+
9
+ #This strategy is applicable when you planning for a AES Encrytion
10
+ #Read more about it here http://ruby-doc.org/stdlib-2.0/libdoc/openssl/rdoc/OpenSSL.html#module-OpenSSL-label-Encryption
11
+ config.encryption_type = :aes
12
+ config.key_size = 256
13
+ end
14
+ "
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave_encrypter_decrypter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ankit gupta
@@ -59,14 +59,17 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - lib/carrierwave/encrypter_decrypter/configuration.rb
63
+ - lib/carrierwave/encrypter_decrypter/decryption.rb
64
+ - lib/carrierwave/encrypter_decrypter/downloader.rb
62
65
  - lib/carrierwave/encrypter_decrypter/encryption.rb
66
+ - lib/carrierwave/encrypter_decrypter/openssl/aes.rb
63
67
  - lib/carrierwave/encrypter_decrypter/uploader.rb
64
- - lib/carrierwave/encrypter_decrypter/downloader.rb
65
- - lib/carrierwave/encrypter_decrypter/decryption.rb
66
- - lib/carrierwave/encrypter_decrypter/configuration.rb
67
68
  - lib/carrierwave/encrypter_decrypter/version.rb
68
- - lib/carrierwave/encrypter_decrypter/openssl/aes.rb
69
69
  - lib/carrierwave_encrypter_decrypter.rb
70
+ - lib/generators/ced.rb
71
+ - lib/generators/ced/install/install_generator.rb
72
+ - Readme.md
70
73
  homepage: https://github.com/ankit8898/carrierwave_encrypter_decrypter
71
74
  licenses:
72
75
  - MIT