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 +4 -4
- data/Readme.md +40 -21
- data/encrypted-keystore.gemspec +1 -1
- data/lib/encrypted_keystore.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1efb8674ad2adb4e1357386f5a63059b6ff90658
|
4
|
+
data.tar.gz: bb5aa9f3ecd876dd115bbb47dd1ef083a701e0ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 201b9ccb705b03a7dbd58ca334f30e4111973a9b62798687d111d673ab5cd22e7425a0edceb73bd6a0987a9cdf844ec848e2c75e30e769ac916a119d1f6997b1
|
7
|
+
data.tar.gz: 36283c5911154d859eb307e546648a4fc7c2448ceb27acc760d7d8e3b690692b9c4d76ee45f704d65bb446aaa45878ad705f5ca3e482d49c0fcbdd3f2fa0172b
|
data/Readme.md
CHANGED
@@ -1,52 +1,71 @@
|
|
1
|
-
#
|
1
|
+
# Encrypted Keystore
|
2
2
|
|
3
|
-
A simple
|
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 '
|
10
|
+
gem 'encrypted-keystore'
|
11
11
|
```
|
12
12
|
|
13
13
|
or install directly:
|
14
14
|
|
15
15
|
```bash
|
16
|
-
gem install
|
16
|
+
gem install encrypted-keystore
|
17
17
|
```
|
18
18
|
|
19
19
|
## Inclusion
|
20
20
|
|
21
|
-
In `config/
|
21
|
+
In `config/application.rb`, include the following:
|
22
22
|
|
23
23
|
```ruby
|
24
|
-
require '
|
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
|
-
|
29
|
+
### Direct Construction
|
30
|
+
|
31
|
+
Encrypt:
|
33
32
|
|
34
33
|
```ruby
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
44
|
+
Decrypt:
|
42
45
|
|
43
46
|
```ruby
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
57
|
+
### Class Methods
|
50
58
|
|
51
|
-
|
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
|
```
|
data/encrypted-keystore.gemspec
CHANGED
data/lib/encrypted_keystore.rb
CHANGED
@@ -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
|