cryptosystem 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/cryptosystem/version.rb +1 -1
- metadata +35 -23
- data/.gitignore +0 -1
- data/.hound.yml +0 -2
- data/.ruby.yml +0 -243
- data/.travis.yml +0 -6
- data/CHANGELOG.md +0 -6
- data/LICENSE +0 -21
- data/README.md +0 -68
- data/Rakefile +0 -8
- data/cryptosystem.gemspec +0 -18
- data/test/cryptosystem/rsa_test.rb +0 -50
- data/test/keys/rsa.key +0 -54
- data/test/keys/rsa.pub +0 -14
- data/test/test_helper.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 60a92f28441852932960ba191b63bcf159e1214e1fc94ce4c5486db82190783a
|
4
|
+
data.tar.gz: a554e013a7c2348ac901e16c5a9aaf1fa5d432d59075686d03df031e01df2374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85170c98dc9f21f081bed153b0fa01dd8e478270cd444ffbfbd05f18e46cb940475c1a1a920d03e5e40f474424aeabf676bad157bc06b26cc7ef53cab9c2e813
|
7
|
+
data.tar.gz: d0be23b0fb2ab51fe609cd3fffc18a29c362dd4298653db75afdbe2566e84a354bb65b9334d403483a304774565107ff1d3fe98894a0d3ec9ab52a00fe0bb259
|
data/lib/cryptosystem/version.rb
CHANGED
metadata
CHANGED
@@ -1,41 +1,54 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptosystem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Wetzel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description:
|
16
42
|
email:
|
17
43
|
executables: []
|
18
44
|
extensions: []
|
19
45
|
extra_rdoc_files: []
|
20
46
|
files:
|
21
|
-
- ".gitignore"
|
22
|
-
- ".hound.yml"
|
23
|
-
- ".ruby.yml"
|
24
|
-
- ".travis.yml"
|
25
|
-
- CHANGELOG.md
|
26
|
-
- LICENSE
|
27
|
-
- README.md
|
28
|
-
- Rakefile
|
29
|
-
- cryptosystem.gemspec
|
30
47
|
- lib/cryptosystem.rb
|
31
48
|
- lib/cryptosystem/base.rb
|
32
49
|
- lib/cryptosystem/exceptions.rb
|
33
50
|
- lib/cryptosystem/rsa.rb
|
34
51
|
- lib/cryptosystem/version.rb
|
35
|
-
- test/cryptosystem/rsa_test.rb
|
36
|
-
- test/keys/rsa.key
|
37
|
-
- test/keys/rsa.pub
|
38
|
-
- test/test_helper.rb
|
39
52
|
homepage:
|
40
53
|
licenses:
|
41
54
|
- MIT
|
@@ -46,7 +59,7 @@ require_paths:
|
|
46
59
|
- lib
|
47
60
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
61
|
requirements:
|
49
|
-
- - "
|
62
|
+
- - ">="
|
50
63
|
- !ruby/object:Gem::Version
|
51
64
|
version: '2'
|
52
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -55,9 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
68
|
- !ruby/object:Gem::Version
|
56
69
|
version: '0'
|
57
70
|
requirements: []
|
58
|
-
|
59
|
-
rubygems_version: 2.5.1
|
71
|
+
rubygems_version: 3.0.3
|
60
72
|
signing_key:
|
61
73
|
specification_version: 4
|
62
|
-
summary: Simple asymmetric (public-key)
|
74
|
+
summary: Simple encryption and decryption with asymmetric (or public-key) cryptography.
|
63
75
|
test_files: []
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
.ruby-version
|
data/.hound.yml
DELETED
data/.ruby.yml
DELETED
@@ -1,243 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
Exclude:
|
3
|
-
- "vendor/**/*"
|
4
|
-
- "db/schema.rb"
|
5
|
-
UseCache: false
|
6
|
-
Style/CollectionMethods:
|
7
|
-
Description: Preferred collection methods.
|
8
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
9
|
-
Enabled: true
|
10
|
-
PreferredMethods:
|
11
|
-
collect: map
|
12
|
-
collect!: map!
|
13
|
-
find: detect
|
14
|
-
find_all: select
|
15
|
-
reduce: inject
|
16
|
-
Style/DotPosition:
|
17
|
-
Description: Checks the position of the dot in multi-line method calls.
|
18
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
19
|
-
Enabled: true
|
20
|
-
EnforcedStyle: trailing
|
21
|
-
SupportedStyles:
|
22
|
-
- leading
|
23
|
-
- trailing
|
24
|
-
Style/FileName:
|
25
|
-
Description: Use snake_case for source file names.
|
26
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
27
|
-
Enabled: false
|
28
|
-
Exclude: []
|
29
|
-
Style/GuardClause:
|
30
|
-
Description: Check for conditionals that can be replaced with guard clauses
|
31
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
|
32
|
-
Enabled: false
|
33
|
-
MinBodyLength: 1
|
34
|
-
Style/IfUnlessModifier:
|
35
|
-
Description: Favor modifier if/unless usage when you have a single-line body.
|
36
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
37
|
-
Enabled: false
|
38
|
-
MaxLineLength: 80
|
39
|
-
Style/OptionHash:
|
40
|
-
Description: Don't use option hashes when you can use keyword arguments.
|
41
|
-
Enabled: false
|
42
|
-
Style/PercentLiteralDelimiters:
|
43
|
-
Description: Use `%`-literal delimiters consistently
|
44
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
|
45
|
-
Enabled: false
|
46
|
-
PreferredDelimiters:
|
47
|
-
"%": "()"
|
48
|
-
"%i": "()"
|
49
|
-
"%q": "()"
|
50
|
-
"%Q": "()"
|
51
|
-
"%r": "{}"
|
52
|
-
"%s": "()"
|
53
|
-
"%w": "()"
|
54
|
-
"%W": "()"
|
55
|
-
"%x": "()"
|
56
|
-
Style/PredicateName:
|
57
|
-
Description: Check the names of predicate methods.
|
58
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
59
|
-
Enabled: true
|
60
|
-
NamePrefix:
|
61
|
-
- is_
|
62
|
-
- has_
|
63
|
-
- have_
|
64
|
-
NamePrefixBlacklist:
|
65
|
-
- is_
|
66
|
-
Exclude:
|
67
|
-
- spec/**/*
|
68
|
-
Style/RaiseArgs:
|
69
|
-
Description: Checks the arguments passed to raise/fail.
|
70
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
|
71
|
-
Enabled: false
|
72
|
-
EnforcedStyle: exploded
|
73
|
-
SupportedStyles:
|
74
|
-
- compact
|
75
|
-
- exploded
|
76
|
-
Style/SignalException:
|
77
|
-
Description: Checks for proper usage of fail and raise.
|
78
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
|
79
|
-
Enabled: false
|
80
|
-
EnforcedStyle: semantic
|
81
|
-
SupportedStyles:
|
82
|
-
- only_raise
|
83
|
-
- only_fail
|
84
|
-
- semantic
|
85
|
-
Style/SingleLineBlockParams:
|
86
|
-
Description: Enforces the names of some block params.
|
87
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
|
88
|
-
Enabled: false
|
89
|
-
Methods:
|
90
|
-
- reduce:
|
91
|
-
- a
|
92
|
-
- e
|
93
|
-
- inject:
|
94
|
-
- a
|
95
|
-
- e
|
96
|
-
Style/SingleLineMethods:
|
97
|
-
Description: Avoid single-line methods.
|
98
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
99
|
-
Enabled: false
|
100
|
-
AllowIfMethodIsEmpty: true
|
101
|
-
Style/StringLiterals:
|
102
|
-
Description: Checks if uses of quotes match the configured preference.
|
103
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
104
|
-
Enabled: true
|
105
|
-
EnforcedStyle: single_quotes
|
106
|
-
SupportedStyles:
|
107
|
-
- single_quotes
|
108
|
-
- double_quotes
|
109
|
-
Style/StringLiteralsInInterpolation:
|
110
|
-
Description: Checks if uses of quotes inside expressions in interpolated strings
|
111
|
-
match the configured preference.
|
112
|
-
Enabled: true
|
113
|
-
EnforcedStyle: single_quotes
|
114
|
-
SupportedStyles:
|
115
|
-
- single_quotes
|
116
|
-
- double_quotes
|
117
|
-
Style/TrailingCommaInArguments:
|
118
|
-
Description: 'Checks for trailing comma in argument lists.'
|
119
|
-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
120
|
-
Enabled: false
|
121
|
-
EnforcedStyleForMultiline: no_comma
|
122
|
-
SupportedStyles:
|
123
|
-
- comma
|
124
|
-
- consistent_comma
|
125
|
-
- no_comma
|
126
|
-
Style/TrailingCommaInLiteral:
|
127
|
-
Description: 'Checks for trailing comma in array and hash literals.'
|
128
|
-
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
129
|
-
Enabled: false
|
130
|
-
EnforcedStyleForMultiline: no_comma
|
131
|
-
SupportedStyles:
|
132
|
-
- comma
|
133
|
-
- consistent_comma
|
134
|
-
- no_comma
|
135
|
-
Metrics/AbcSize:
|
136
|
-
Description: A calculated magnitude based on number of assignments, branches, and
|
137
|
-
conditions.
|
138
|
-
Enabled: false
|
139
|
-
Max: 15
|
140
|
-
Metrics/ClassLength:
|
141
|
-
Description: Avoid classes longer than 100 lines of code.
|
142
|
-
Enabled: false
|
143
|
-
CountComments: false
|
144
|
-
Max: 100
|
145
|
-
Metrics/ModuleLength:
|
146
|
-
CountComments: false
|
147
|
-
Max: 100
|
148
|
-
Description: Avoid modules longer than 100 lines of code.
|
149
|
-
Enabled: false
|
150
|
-
Metrics/CyclomaticComplexity:
|
151
|
-
Description: A complexity metric that is strongly correlated to the number of test
|
152
|
-
cases needed to validate a method.
|
153
|
-
Enabled: false
|
154
|
-
Max: 6
|
155
|
-
Metrics/MethodLength:
|
156
|
-
Description: Avoid methods longer than 10 lines of code.
|
157
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
|
158
|
-
Enabled: false
|
159
|
-
CountComments: false
|
160
|
-
Max: 10
|
161
|
-
Metrics/ParameterLists:
|
162
|
-
Description: Avoid parameter lists longer than three or four parameters.
|
163
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
|
164
|
-
Enabled: false
|
165
|
-
Max: 5
|
166
|
-
CountKeywordArgs: true
|
167
|
-
Metrics/PerceivedComplexity:
|
168
|
-
Description: A complexity metric geared towards measuring complexity for a human
|
169
|
-
reader.
|
170
|
-
Enabled: false
|
171
|
-
Max: 7
|
172
|
-
Lint/AssignmentInCondition:
|
173
|
-
Description: Don't use assignment in conditions.
|
174
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
|
175
|
-
Enabled: false
|
176
|
-
AllowSafeAssignment: true
|
177
|
-
Style/InlineComment:
|
178
|
-
Description: Avoid inline comments.
|
179
|
-
Enabled: false
|
180
|
-
Style/AccessorMethodName:
|
181
|
-
Description: Check the naming of accessor methods for get_/set_.
|
182
|
-
Enabled: false
|
183
|
-
Style/Alias:
|
184
|
-
Description: Use alias_method instead of alias.
|
185
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
|
186
|
-
Enabled: false
|
187
|
-
Style/Documentation:
|
188
|
-
Description: Document classes and non-namespace modules.
|
189
|
-
Enabled: false
|
190
|
-
Style/DoubleNegation:
|
191
|
-
Description: Checks for uses of double negation (!!).
|
192
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
|
193
|
-
Enabled: false
|
194
|
-
Style/EachWithObject:
|
195
|
-
Description: Prefer `each_with_object` over `inject` or `reduce`.
|
196
|
-
Enabled: false
|
197
|
-
Style/EmptyLiteral:
|
198
|
-
Description: Prefer literals to Array.new/Hash.new/String.new.
|
199
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
|
200
|
-
Enabled: false
|
201
|
-
Style/ModuleFunction:
|
202
|
-
Description: Checks for usage of `extend self` in modules.
|
203
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
|
204
|
-
Enabled: false
|
205
|
-
Style/OneLineConditional:
|
206
|
-
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
207
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
208
|
-
Enabled: false
|
209
|
-
Style/PerlBackrefs:
|
210
|
-
Description: Avoid Perl-style regex back references.
|
211
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
212
|
-
Enabled: false
|
213
|
-
Style/Send:
|
214
|
-
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
|
215
|
-
may overlap with existing methods.
|
216
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
|
217
|
-
Enabled: false
|
218
|
-
Style/SpecialGlobalVars:
|
219
|
-
Description: Avoid Perl-style global variables.
|
220
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
|
221
|
-
Enabled: false
|
222
|
-
Style/VariableInterpolation:
|
223
|
-
Description: Don't interpolate global, instance and class variables directly in
|
224
|
-
strings.
|
225
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
|
226
|
-
Enabled: false
|
227
|
-
Style/WhenThen:
|
228
|
-
Description: Use when x then ... for one-line cases.
|
229
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
230
|
-
Enabled: false
|
231
|
-
Lint/EachWithObjectArgument:
|
232
|
-
Description: Check for immutable argument given to each_with_object.
|
233
|
-
Enabled: true
|
234
|
-
Lint/HandleExceptions:
|
235
|
-
Description: Don't suppress exception.
|
236
|
-
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
237
|
-
Enabled: false
|
238
|
-
Lint/LiteralInCondition:
|
239
|
-
Description: Checks of literals used in conditions.
|
240
|
-
Enabled: false
|
241
|
-
Lint/LiteralInInterpolation:
|
242
|
-
Description: Checks for literals used in interpolation.
|
243
|
-
Enabled: false
|
data/.travis.yml
DELETED
data/CHANGELOG.md
DELETED
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2016 Josh Wetzel
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
data/README.md
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/cryptosystem.svg)](https://badge.fury.io/rb/cryptosystem)
|
2
|
-
[![Build Status](https://travis-ci.org/jdubswe/cryptosystem.svg?branch=master)](https://travis-ci.org/jdubswe/cryptosystem)
|
3
|
-
|
4
|
-
# Cryptosystem
|
5
|
-
Cryptosystem is a Ruby library facilitating simple encryption and decryption with asymmetric cryptography (or public-key
|
6
|
-
cryptography). At this time, only RSA is supported.
|
7
|
-
|
8
|
-
## Installation
|
9
|
-
In your Gemfile, include the `cryptosystem` gem and then `bundle install`.
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'cryptosystem'
|
13
|
-
```
|
14
|
-
|
15
|
-
## Getting Started
|
16
|
-
In order to encrypt and decrypt, a public and private key must be generated.
|
17
|
-
|
18
|
-
```bash
|
19
|
-
$ openssl genrsa -out private.key
|
20
|
-
$ openssl rsa -in private.key -pubout > public.pub
|
21
|
-
```
|
22
|
-
|
23
|
-
## Configuration
|
24
|
-
Cryptosystem must know the path and password to your private key as well as the path to your public key.
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
# config/initializers/cryptosystem.rb
|
28
|
-
|
29
|
-
Cryptosystem::RSA.configure do |config|
|
30
|
-
config.password = ENV['secret-password']
|
31
|
-
config.private_key_path = 'path/to/private.key'
|
32
|
-
config.public_key_path = 'path/to/public.pub'
|
33
|
-
end
|
34
|
-
```
|
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
|
-
|
48
|
-
## Encrypting
|
49
|
-
After generating a key pair and properly configuring Cryptosystem, encryption is straightforward.
|
50
|
-
|
51
|
-
```ruby
|
52
|
-
rsa = Cryptosystem::RSA.new
|
53
|
-
rsa.encrypt('secret') # => "JxpuhTpEqRtMLmaSfaq/X6XONkBnMe..."
|
54
|
-
```
|
55
|
-
|
56
|
-
The encrypted value is Base64 encoded, making it suitable for database storage.
|
57
|
-
|
58
|
-
## Decrypting
|
59
|
-
Decrypting is as simple as passing in an encrypted, Base64 encoded value.
|
60
|
-
|
61
|
-
```ruby
|
62
|
-
rsa = Cryptosystem::RSA.new
|
63
|
-
encrypted_value = rsa.encrypt('secret') # => "Y8DWJc2/+7TIxdLEolV99XI2sclHuK..."
|
64
|
-
rsa.decrypt(encrypted_value) # => "secret"
|
65
|
-
```
|
66
|
-
|
67
|
-
## Acknowledgments
|
68
|
-
Special thanks to [@jedspurg](https://github.com/jedspurg) for the inspiration for this project.
|
data/Rakefile
DELETED
data/cryptosystem.gemspec
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'cryptosystem/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = 'cryptosystem'
|
8
|
-
s.version = Cryptosystem::VERSION
|
9
|
-
s.files = `git ls-files`.split($/)
|
10
|
-
s.summary = 'Simple asymmetric (public-key) encryption.'
|
11
|
-
s.description = <<-DESC
|
12
|
-
Cryptosystem is a Ruby library facilitating simple encryption and
|
13
|
-
decryption with asymmetric cryptography (or public-key cryptography).
|
14
|
-
DESC
|
15
|
-
s.author = 'Josh Wetzel'
|
16
|
-
s.license = 'MIT'
|
17
|
-
s.required_ruby_version = '~> 2'
|
18
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class RSATest < Minitest::Test
|
4
|
-
def setup
|
5
|
-
@rsa = Cryptosystem::RSA.new
|
6
|
-
end
|
7
|
-
|
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
|
-
|
20
|
-
assert_equal Cryptosystem::RSA.password, @rsa.password
|
21
|
-
assert_equal File.expand_path(@rsa.private_key_path), @rsa.private_key_path
|
22
|
-
assert_equal File.expand_path(@rsa.public_key_path), @rsa.public_key_path
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_value_is_encrypted
|
26
|
-
encrypted_value = @rsa.encrypt('test')
|
27
|
-
refute_equal 'test', encrypted_value
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_value_is_decrypted
|
31
|
-
encrypted_value = @rsa.encrypt('test')
|
32
|
-
assert_equal 'test', @rsa.decrypt(encrypted_value)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_encrypted_value_is_base64_encoded
|
36
|
-
assert Base64.strict_decode64(@rsa.encrypt('test'))
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_decrypted_value_is_base64_decoded
|
40
|
-
assert Base64.strict_encode64(@rsa.decrypt(@rsa.encrypt('test')))
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_encrypting_nil_value_returns_nil
|
44
|
-
assert_nil @rsa.encrypt(nil)
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_decrypting_nil_value_returns_nil
|
48
|
-
assert_nil @rsa.decrypt(nil)
|
49
|
-
end
|
50
|
-
end
|
data/test/keys/rsa.key
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
-----BEGIN RSA PRIVATE KEY-----
|
2
|
-
Proc-Type: 4,ENCRYPTED
|
3
|
-
DEK-Info: AES-256-CBC,2C31524529382C7E48A2056847C3497F
|
4
|
-
|
5
|
-
TECTnAsv91gK5+5Yjh1sXsCZ8ZEvLu5UkNKHxFeKGQ0T5aPLRDW4RQM7+agn+m/7
|
6
|
-
MwlNJFHDKbpOh10VJjar3ytBIYOhMWHZwHyFXNMK8GBSD012MAdPTssixtXAdoHE
|
7
|
-
GojwKruvokspgyBdNvsCopLXSPDtfyKUkz2gJTbZ9fZ4TZyaPOeA3v+m6m9r8JHS
|
8
|
-
vGk9JPcNEvg8CmKmakivSWfsYKo3bFje4qwigMWw9dU0S1P41ArXRPBTLojzJAKv
|
9
|
-
3jTVF/v0+a+QD1yRQ0dffO51BscXt7jBRmuC/2SHj9X1pEWsNMY/mb8cPVVrS0UD
|
10
|
-
hsBnoAU8+7ZxJzrlQLorOKMHLm5EXTcf09CI1YiEbp0NuRvgvw48l5TnCBk3ecVT
|
11
|
-
YpRIaJPpRuOg1wPlt6ZkG7cVzfj6w/pozo88eilYuqVUh2AFPaK6wMN72NGilFB+
|
12
|
-
t8aSD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FUQaVsvf8+LtQ2
|
3
|
-
3eajUhyM+kP0CMwMc/S7epWKD2JqATSaJUrluvrBP32NxVEyB1d/3nbS9Hq245Qv
|
4
|
-
wtMaTqkxUMpT1TMXZpXOacNeSvFobgAbXSSH4lMuaemVxqgAPrNYF3AP/OVFLJ3X
|
5
|
-
zjdLvz63oYdjAwwy7GwBlbxpCL4081p7f1/Ex+RpAHud9ZXAdXbZSam/zk1A2VAC
|
6
|
-
/ndeC53UF5y//sSeheFByCwOZUeUXrGEFur9hm3oWwBRdY3sCV9pXe6uxBSyca54
|
7
|
-
hUWsO3Ma2ooEvqI2TvB+k4KYJyJS5yhd9s31bTkhznWovzgQONIXxQNr62b2V2yL
|
8
|
-
N/XOtQWYYs3zrDsITdnAIExKq9fzUEP8848+PYzDSaAuvUs2bb592gqOnukzCnyz
|
9
|
-
OovgEbb7Im6cem29x65ym+K0iRU9m4CYCUV4wiaeHKcb6QkuBetGAR0O+dXF25ku
|
10
|
-
T00M0Xta32ss5cYkRWVy44YiQVf4uuDqhrwgoE4gRsNQrvxcW9F6umhoG+yLQxLL
|
11
|
-
lKT1ZavWUO6fW9unKXRKwrrQSf26cAkziLzuzkgeaZf7k8GOJC/bv5XQZvh05AoK
|
12
|
-
C+EiisjnJqPhTGJCmh1ej60Ca7zMnlyojV8bmVagBGo3U1cVHQPQE6nPjjK46OMd
|
13
|
-
KANRPBzvPT+ZZQmzQereaksCAwEAAQ==
|
14
|
-
-----END PUBLIC KEY-----
|
data/test/test_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'cryptosystem'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
|
4
|
-
if !defined?(Minitest::Test)
|
5
|
-
Minitest::Test = MiniTest::Unit::TestCase
|
6
|
-
end
|
7
|
-
|
8
|
-
Cryptosystem::RSA.configure do |config|
|
9
|
-
config.password = 'test'
|
10
|
-
config.private_key_path = 'test/keys/rsa.key'
|
11
|
-
config.public_key_path = 'test/keys/rsa.pub'
|
12
|
-
end
|