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 +4 -4
- data/lib/shhh/application.rb +5 -3
- data/lib/shhh/encrypted_file.rb +34 -0
- data/lib/shhh/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3719455248b51396f2f9e61a118831781ed9cfde
|
4
|
+
data.tar.gz: 18fa87873719241498d30f3490bb1db8d5f91f1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0009d955c698e4dca1a76dbff0ce0d764d2fd1c624afff258f9900e09ebc01430e3ba3cee3345aa1bb70a81d79fb9e48bafe650a10a080bf68c005aadcbd199
|
7
|
+
data.tar.gz: 36fbc0bae8fa2c4ced54d8dfe822630b39d84767c1d939fee3dfe7ec749a4df0c94ac1e6b071e1ea64f693cb518ebcfc92b676ad6430318f4e3f6142f6f2c42d
|
data/lib/shhh/application.rb
CHANGED
@@ -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
|
-
|
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
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.
|
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
|