encryption 1.1.3 → 1.1.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 +15 -0
- data/README.md +5 -1
- data/encryption.gemspec +1 -1
- data/lib/helpers/string.rb +9 -3
- data/spec/helpers/string_spec.rb +23 -0
- metadata +5 -7
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2FiOTRlYTljMTJhM2I2OTZjOWU2YTc0ZDk3ODU5OGU1OTIzOWRlZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZmZjNTdkZDlhNDBiMDE0ZDI0NzZhYWE3OGY1OTI0MTAwNzJkNzBiZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDA5MTM4MjZmYmE3YTFiOGZiZTk4MDZjNWRkMWI1NjZkMTJkNGU1N2MzYTY0
|
10
|
+
YzYxNGYyM2QxNTA2Y2YxMDE1N2Q3YjlmOTE4MDYyNmQxMDYwOWE3OGQ3NGY5
|
11
|
+
ZmJkM2NhZWVhNzc0ZGM2YTA5NTA2MzU4NzQyYmJkNzg5YTIzYTk=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YzBjYTBmMGFiYzE2MWE0MjYyMTQzMTc4YTFjMGNiZmFjYmVhZWI2YWY0NGJm
|
14
|
+
YzU1MTYxNTBmNjY3ZTg2NjNlZGZlNWEzM2Q5ZTI3MDJmNTUwZDIzMmRlODJh
|
15
|
+
N2IyZGQzYmYzNzc3ODE4NjEyYWY4OTk5NmM3Mjc4MGIwYmNmYTI=
|
data/README.md
CHANGED
@@ -112,7 +112,11 @@ Helpers
|
|
112
112
|
"h3LL0".decrypt!
|
113
113
|
|
114
114
|
# With custom settings (and custom encryptor instance)
|
115
|
-
"Contact".encrypt(
|
115
|
+
"Contact".encrypt(key: 'encryption key', iv: 'initialization vector', cipher: 'encryption algorithm', encode: true)
|
116
|
+
|
117
|
+
# Note the encode option which will result in a base64 encoded string
|
118
|
+
|
119
|
+
"3NcPyptED".decrypt!(encoded: true) # Will decrypt an encoded string
|
116
120
|
|
117
121
|
# Or with a custom encryptor
|
118
122
|
encryptor = Encryption::Symmetric.new
|
data/encryption.gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'date'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'encryption'
|
5
|
-
s.version = '1.1.
|
5
|
+
s.version = '1.1.4'
|
6
6
|
s.date = Date.today.to_s
|
7
7
|
s.summary = 'A simple wrapper for the OpenSSL Cipher library'
|
8
8
|
s.description = 'Encryption provides a simple interface for symmetric / asymmetric encryption with the OpenSSL Cipher library'
|
data/lib/helpers/string.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
1
3
|
module Encryption
|
2
4
|
module String
|
3
5
|
|
4
6
|
def encrypt(options = {})
|
5
|
-
encryptor(options).encrypt self
|
7
|
+
string = encryptor(options).encrypt self
|
8
|
+
string = Base64.encode64(string) if options[:encode]
|
9
|
+
string
|
6
10
|
end
|
7
11
|
|
8
12
|
def decrypt(options = {})
|
9
|
-
|
13
|
+
string = self
|
14
|
+
string = Base64.decode64(self) if options[:encode] or options[:encoded]
|
15
|
+
encryptor(options).decrypt string
|
10
16
|
end
|
11
17
|
|
12
18
|
def encrypt!(options = {})
|
@@ -26,7 +32,7 @@ module Encryption
|
|
26
32
|
encrypt = Encryption::Symmetric.new
|
27
33
|
|
28
34
|
options.each do |key, value|
|
29
|
-
encrypt.send(key.to_s + '=', value)
|
35
|
+
encrypt.send(key.to_s + '=', value) if encrypt.respond_to? key.to_s + '='
|
30
36
|
end
|
31
37
|
|
32
38
|
encrypt
|
data/spec/helpers/string_spec.rb
CHANGED
@@ -60,4 +60,27 @@ describe String do
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
describe 'with encode option' do
|
64
|
+
before(:each) do
|
65
|
+
@string = String.random
|
66
|
+
@options = {
|
67
|
+
:key => String.random,
|
68
|
+
:iv => String.random,
|
69
|
+
:encode => true
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should generate encryption different then the original string' do
|
74
|
+
@string.encrypt(@options).should_not == @string
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should generate a valid base64' do
|
78
|
+
(@string.encrypt(@options)=~/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/).should == 0
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should decrypt, encrypted values and match the original string' do
|
82
|
+
@string.encrypt(@options).decrypt(@options).should == @string
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
63
86
|
end
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: encryption
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Itay Grudev
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Encryption provides a simple interface for symmetric / asymmetric encryption
|
15
14
|
with the OpenSSL Cipher library
|
@@ -54,26 +53,25 @@ files:
|
|
54
53
|
homepage: https://github.com/Itehnological/encryption
|
55
54
|
licenses:
|
56
55
|
- MIT
|
56
|
+
metadata: {}
|
57
57
|
post_install_message:
|
58
58
|
rdoc_options: []
|
59
59
|
require_paths:
|
60
60
|
- lib
|
61
61
|
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
-
none: false
|
63
62
|
requirements:
|
64
63
|
- - ! '>='
|
65
64
|
- !ruby/object:Gem::Version
|
66
65
|
version: '0'
|
67
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
67
|
requirements:
|
70
68
|
- - ! '>='
|
71
69
|
- !ruby/object:Gem::Version
|
72
70
|
version: '0'
|
73
71
|
requirements: []
|
74
72
|
rubyforge_project:
|
75
|
-
rubygems_version:
|
73
|
+
rubygems_version: 2.0.3
|
76
74
|
signing_key:
|
77
|
-
specification_version:
|
75
|
+
specification_version: 4
|
78
76
|
summary: A simple wrapper for the OpenSSL Cipher library
|
79
77
|
test_files: []
|