encrypted-keystore 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f702b8696648c43bef8b8b61cf0da1c42b57e38a
4
- data.tar.gz: 47b8ec4c2fd696497a1ddc1e84da6a4c84526d49
3
+ metadata.gz: 1efb8674ad2adb4e1357386f5a63059b6ff90658
4
+ data.tar.gz: bb5aa9f3ecd876dd115bbb47dd1ef083a701e0ed
5
5
  SHA512:
6
- metadata.gz: c6dae5d82995e25913827aa3781d3a1b43a2ed7d5075b3ef1086602ec9db2c835b8aca6c42cbdeaef9879749176a7584862a17ef393fbf6f21911dd5e63c8d6d
7
- data.tar.gz: aa2347013272c0a6bf155f9a07175cd7380b3200eb1f9b334866243342904760457d303844feafa4113784505a1eb5cc72c47d63a6090cc320714a92fa2d14c8
6
+ metadata.gz: 201b9ccb705b03a7dbd58ca334f30e4111973a9b62798687d111d673ab5cd22e7425a0edceb73bd6a0987a9cdf844ec848e2c75e30e769ac916a119d1f6997b1
7
+ data.tar.gz: 36283c5911154d859eb307e546648a4fc7c2448ceb27acc760d7d8e3b690692b9c4d76ee45f704d65bb446aaa45878ad705f5ca3e482d49c0fcbdd3f2fa0172b
data/Readme.md CHANGED
@@ -1,52 +1,71 @@
1
- # Rails, Quietly
1
+ # Encrypted Keystore
2
2
 
3
- A simple wrapper to suppress logging in various ways in Rails apps.
3
+ A simple encrypted key storage system.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this to your Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'rails-quietly'
10
+ gem 'encrypted-keystore'
11
11
  ```
12
12
 
13
13
  or install directly:
14
14
 
15
15
  ```bash
16
- gem install rails-quietly
16
+ gem install encrypted-keystore
17
17
  ```
18
18
 
19
19
  ## Inclusion
20
20
 
21
- In `config/applicaiton.rb`, include the following:
21
+ In `config/application.rb`, include the following:
22
22
 
23
23
  ```ruby
24
- require 'quietly'
25
- include Quietly::Local
24
+ require 'encrypted_keystore'
26
25
  ```
27
26
 
28
- This puts the module into global scope.
29
-
30
27
  ## Usage
31
28
 
32
- You can either use the `quietly` method with a block:
29
+ ### Direct Construction
30
+
31
+ Encrypt:
33
32
 
34
33
  ```ruby
35
- result_b = quietly do
36
- a = ModelA.query
37
- ModelB.query(a)
38
- end
34
+ ek = EncryptedKeystore.new(
35
+ file: 'path/to/key.pem',
36
+ out: 'path/to/encrypted.pem.enc'
37
+ )
38
+
39
+ ek.encrypt
40
+ key = ek.key
41
+ iv = ek.iv
39
42
  ```
40
43
 
41
- or manually suppress and restore logging:
44
+ Decrypt:
42
45
 
43
46
  ```ruby
44
- old_logger = go_quiet
45
-
46
- a = ModelA.query
47
- result_b = ModelB.query(a)
47
+ ek = EncryptedKeystore.new(
48
+ file: 'path/to/encrypted.pem.enc',
49
+ out: 'path/to/key.pem',
50
+ key: key,
51
+ iv: iv
52
+ )
53
+
54
+ ek.decrypt
55
+ ```
48
56
 
49
- end_quiet(old_logger)
57
+ ### Class Methods
50
58
 
51
- result_b
59
+ ```ruby
60
+ key_hash = EncryptedKeystore.encrypt(
61
+ file: 'path/to/key.pem',
62
+ out: 'path/to/encrypted.pem.enc'
63
+ )
64
+
65
+ EncryptedKeystore.decrypt(
66
+ file: 'path/to/encrypted.pem.enc',
67
+ out: 'path/to/key.pem',
68
+ key: key,
69
+ iv: iv
70
+ )
52
71
  ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'encrypted-keystore'
5
- s.version = '0.0.3'
5
+ s.version = '0.0.4'
6
6
  s.date = '2019-06-26'
7
7
  s.summary = 'Simple key encrypter/decrypter'
8
8
  s.description = 'A simple encrypted key storage system.'
@@ -6,6 +6,18 @@ class EncryptedKeystore
6
6
 
7
7
  attr_accessor :file, :out, :key, :iv
8
8
 
9
+ def self.encrypt(file, out)
10
+ enc = new(file: file, out: out)
11
+ enc.encrypt
12
+
13
+ { key: enc.key, iv: enc.iv }
14
+ end
15
+
16
+ def self.decrypt(file, out, key, iv)
17
+ enc = new(file: file, out: out, key: key, iv: iv)
18
+ enc.decrypt
19
+ end
20
+
9
21
  def initialize(file: nil, out: nil, key: nil, iv: nil)
10
22
  @file = file
11
23
  @out = out
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: encrypted-keystore
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
  - Julian Fiander