shhh 1.6.2 → 1.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b69dc1f273a6c0e894b93d546b77d496cc533ea
4
- data.tar.gz: e25fae154b281b834d705f2cff152e577fa910bd
3
+ metadata.gz: 3719455248b51396f2f9e61a118831781ed9cfde
4
+ data.tar.gz: 18fa87873719241498d30f3490bb1db8d5f91f1d
5
5
  SHA512:
6
- metadata.gz: 50bbac49d69efebfdb355603c32f468c51448b55c161e915d78f0319c8096789d0d9cef5a41a6ae99e0ef48c2b6c5a012a74a3a46b3e999a116f80f8c130db69
7
- data.tar.gz: 056789fe26fefb51707277ff2d05564a7d9eea886b33e838899275bfe1f1b547be9ecce07af88951cbfe910dda8095951e836dd80209a71c13766bf4e298359e
6
+ metadata.gz: f0009d955c698e4dca1a76dbff0ce0d764d2fd1c624afff258f9900e09ebc01430e3ba3cee3345aa1bb70a81d79fb9e48bafe650a10a080bf68c005aadcbd199
7
+ data.tar.gz: 36fbc0bae8fa2c4ced54d8dfe822630b39d84767c1d939fee3dfe7ec749a4df0c94ac1e6b071e1ea64f693cb518ebcfc92b676ad6430318f4e3f6142f6f2c42d
@@ -29,7 +29,7 @@ module Shhh
29
29
  end
30
30
  end
31
31
 
32
- def execute
32
+ def execute!
33
33
  if args.do_options_require_key? || args.do_options_specify_key?
34
34
  self.key = Shhh::App::PrivateKey::Handler.new(opts, input_handler).key
35
35
  raise Shhh::Errors::NoPrivateKeyFound.new('Private key is required') unless self.key
@@ -39,9 +39,11 @@ module Shhh
39
39
  raise Shhh::Errors::InsufficientOptionsError.new(
40
40
  'Can not determine what to do from the options ' + opts_hash.keys.reject { |k| !opts[k] }.to_s)
41
41
  end
42
-
43
42
  self.result = command.execute
44
- return result
43
+ end
44
+
45
+ def execute
46
+ execute!
45
47
 
46
48
  rescue ::OpenSSL::Cipher::CipherError => e
47
49
  error type: 'Cipher Error',
@@ -0,0 +1,34 @@
1
+ require 'shhh'
2
+ require 'shhh/application'
3
+ require 'shhh/app/args'
4
+
5
+ module Shhh
6
+ # This class provides a convenience wrapper for opening and reading
7
+ # encrypted files as they were regular files, and then possibly writing
8
+ # changes to them later.
9
+
10
+ class EncryptedFile
11
+
12
+ include Shhh
13
+
14
+ attr_reader :application, :file, :key_id, :key_type, :app_args
15
+
16
+ def initialize(file:, key_id:, key_type:)
17
+ @file = file
18
+ @key_id = key_id
19
+ @key_type = key_type.to_sym
20
+ @app_args = { file: file, key_type => key_id, decrypt: true }
21
+ @application = Shhh::Application.new(self.app_args)
22
+ end
23
+
24
+ def read
25
+ @content = application.execute! unless @content
26
+ @content
27
+ end
28
+
29
+ def write
30
+ Shhh::Application.new(file: file, key_type => key_id, encrypt: true, output: file).execute
31
+ end
32
+ end
33
+ end
34
+
data/lib/shhh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Shhh
2
- VERSION = '1.6.2'
2
+ VERSION = '1.6.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shhh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.2
4
+ version: 1.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul
@@ -233,6 +233,7 @@ files:
233
233
  - lib/shhh/data/decoder.rb
234
234
  - lib/shhh/data/encoder.rb
235
235
  - lib/shhh/data/wrapper_struct.rb
236
+ - lib/shhh/encrypted_file.rb
236
237
  - lib/shhh/errors.rb
237
238
  - lib/shhh/extensions/class_methods.rb
238
239
  - lib/shhh/extensions/instance_methods.rb