cryptosystem 0.0.1 → 0.0.2

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: 85f438691a896bf64fe02231dd5af6186823a5b6
4
- data.tar.gz: 3699e93c8c639527d01d76316d09ddd36a792cde
3
+ metadata.gz: dbdf320cd42c830082a2bca1375b73004bf92959
4
+ data.tar.gz: 0db0d1bcce0cf3f9aed1674184083b3eb48fb219
5
5
  SHA512:
6
- metadata.gz: 66f44adf68b69c9a90d4dac52aba7bed93fb7454ca772f8a15a8ffa8157fbf38bdc5b400b548f4515dea5f2de3c4740cd8070565cfdb21e7f84701ed88e9eb48
7
- data.tar.gz: d504380686a8ebadd9761e2e93ea9464b980641e4aafa120c12531b270ccc78b645d8e1ff093a2c4e0da4df3d3161c2e05a1bfbee3ad510b363fec1a12f24547
6
+ metadata.gz: 6e68f62f02df25218c7830bd2c6d4d7fbf0260945e4bba0af746e8afdd2ce54555e645f3bd682c8258a5a1969c63837d64a1172508bb7890a1def388e45334d8
7
+ data.tar.gz: 634bcf5ed8dc0bc81e5d8f8a74ecf4f78482f83dcbb746552a54856bbe620890267145963cb535d85ee06cc6fb9ee153864c041bbcf53a810f7e790e3e2e1996
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ #### 0.0.2
2
+ * Allow configuration options to be passed in or overridden during instantiation.
3
+
1
4
  #### 0.0.1
2
5
  * Encrypting a `nil` value returns `nil` instead of `EncryptError`.
3
6
  * Decrypting a `nil` value returns `nil` instead of `DecryptError`.
data/README.md CHANGED
@@ -33,6 +33,18 @@ Cryptosystem::RSA.configure do |config|
33
33
  end
34
34
  ```
35
35
 
36
+ Configuration options may also be passed in or overridden when instantiating a new object.
37
+
38
+ ```ruby
39
+ config = {
40
+ password: ENV['secret-password'],
41
+ private_key_path: 'path/to/private.key',
42
+ public_key_path: 'path/to/public.pub'
43
+ }
44
+
45
+ rsa = Cryptosystem::RSA.new(config)
46
+ ```
47
+
36
48
  ## Encrypting
37
49
  After generating a key pair and properly configuring Cryptosystem, encryption is straightforward.
38
50
 
@@ -10,10 +10,10 @@ module Cryptosystem
10
10
  attr_reader :private_key_path
11
11
  attr_reader :public_key_path
12
12
 
13
- def initialize
14
- @password = Cryptosystem::RSA.password
15
- @private_key_path = expand_path(Cryptosystem::RSA.private_key_path)
16
- @public_key_path = expand_path(Cryptosystem::RSA.public_key_path)
13
+ def initialize(config = {})
14
+ @password = config[:password] || Cryptosystem::RSA.password
15
+ @private_key_path = expand_path(config[:private_key_path] || Cryptosystem::RSA.private_key_path)
16
+ @public_key_path = expand_path(config[:public_key_path] || Cryptosystem::RSA.public_key_path)
17
17
  rescue => error
18
18
  raise ConfigurationError, error.message
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module Cryptosystem
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
@@ -6,6 +6,17 @@ class RSATest < Minitest::Test
6
6
  end
7
7
 
8
8
  def test_initialize
9
+ config = {
10
+ password: 'override',
11
+ private_key_path: 'override.key',
12
+ public_key_path: 'override.pub'
13
+ }
14
+
15
+ rsa = Cryptosystem::RSA.new(config)
16
+ assert_equal config[:password], rsa.password
17
+ assert_equal File.expand_path(config[:private_key_path]), rsa.private_key_path
18
+ assert_equal File.expand_path(config[:public_key_path]), rsa.public_key_path
19
+
9
20
  assert_equal Cryptosystem::RSA.password, @rsa.password
10
21
  assert_equal File.expand_path(@rsa.private_key_path), @rsa.private_key_path
11
22
  assert_equal File.expand_path(@rsa.public_key_path), @rsa.public_key_path
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptosystem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Wetzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-18 00:00:00.000000000 Z
11
+ date: 2016-05-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Cryptosystem is a Ruby library facilitating simple encryption and