easy-crypto 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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/easycrypto/crypto.rb +1 -1
- data/lib/easycrypto/key.rb +2 -1
- data/lib/easycrypto/version.rb +1 -1
- data/spec/easycrypto/crypto_spec.rb +9 -0
- data/spec/easycrypto/key_spec.rb +18 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71d9dc94fea524015ddc5f2494d20b6617bae68d440b5e253dd223738b7b10b8
|
4
|
+
data.tar.gz: 0d90bae4172a48debda1ba2e9c222ed0f99deb537ba5ae86201bf2ce41134bc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88db5fd08c7d5ecbcc4dc6695d848d2a052afa41be8e0c0d78a0b3a3572ad60d3eb25016346856bddbad2e964b6e57de9e5518ef24293a85c150b612a15b5e61
|
7
|
+
data.tar.gz: 6a2f42b3f6c2c8dd3148068c213591537fc832bc58842f039a5837567774cb64cc538bf81b757d68e6b2f3ef21bbf68b24ec04b55bb9106a2d86cd6c1acae416
|
data/Gemfile.lock
CHANGED
data/lib/easycrypto/crypto.rb
CHANGED
data/lib/easycrypto/key.rb
CHANGED
@@ -7,6 +7,7 @@ module EasyCrypto
|
|
7
7
|
ITERATION_COUNT = 10_000
|
8
8
|
KEY_LENGTH = 32
|
9
9
|
HASH_ALGO = 'sha256'
|
10
|
+
DEFAULT_SALT_LENGTH = 12
|
10
11
|
|
11
12
|
attr_reader :key, :salt
|
12
13
|
|
@@ -15,7 +16,7 @@ module EasyCrypto
|
|
15
16
|
@salt = salt
|
16
17
|
end
|
17
18
|
|
18
|
-
def self.generate(password, salt_length)
|
19
|
+
def self.generate(password, salt_length = DEFAULT_SALT_LENGTH)
|
19
20
|
salt = OpenSSL::Random.random_bytes(salt_length)
|
20
21
|
key = OpenSSL::KDF.pbkdf2_hmac(
|
21
22
|
password,
|
data/lib/easycrypto/version.rb
CHANGED
@@ -4,4 +4,13 @@ RSpec.describe EasyCrypto::Crypto do
|
|
4
4
|
it 'has a version number' do
|
5
5
|
expect(EasyCrypto::VERSION).not_to be nil
|
6
6
|
end
|
7
|
+
|
8
|
+
context 'encrypt' do
|
9
|
+
it 'returns encrypted text in a single line' do
|
10
|
+
ecrypto = EasyCrypto::Crypto.new
|
11
|
+
key = EasyCrypto::Key.generate('key password', 12)
|
12
|
+
encrypted = ecrypto.encrypt_with_key(key, 'plain text')
|
13
|
+
expect(encrypted).not_to include("\n")
|
14
|
+
end
|
15
|
+
end
|
7
16
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'easycrypto'
|
2
|
+
|
3
|
+
RSpec.describe EasyCrypto::Key do
|
4
|
+
|
5
|
+
context 'generate' do
|
6
|
+
it 'returns key with a salt of the specified length' do
|
7
|
+
key = EasyCrypto::Key.generate('key password', 24)
|
8
|
+
|
9
|
+
expect(key.salt.length).to be 24
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns key with a 12 byte length salt' do
|
13
|
+
key = EasyCrypto::Key.generate('key password')
|
14
|
+
|
15
|
+
expect(key.salt.length).to be 12
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy-crypto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emarsys Security
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/easycrypto/key.rb
|
93
93
|
- lib/easycrypto/version.rb
|
94
94
|
- spec/easycrypto/crypto_spec.rb
|
95
|
+
- spec/easycrypto/key_spec.rb
|
95
96
|
- spec/spec_helper.rb
|
96
97
|
homepage: https://github.com/emartech/ruby-easy-crypto
|
97
98
|
licenses:
|