sha256_seal 0.1.3 → 0.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 +4 -4
- data/.gitignore +8 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +5 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +60 -0
- data/README.md +47 -0
- data/Rakefile +22 -0
- data/VERSION.semver +1 -0
- data/bin/console +8 -0
- data/bin/setup +7 -0
- data/lib/sha256_seal.rb +39 -0
- data/sha256_seal.gemspec +27 -0
- metadata +15 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64db1f61edfc475755906217a51b68ae2fb6cc73b222464c57a5a8c2225d7ca5
|
4
|
+
data.tar.gz: cb01c03364b3e87db6e8f8765c820bf97a56e52007313a8ca03d3843cf91bb93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff9b8f59a96112330fd803d01f3cffb360aaf9cc3adcc30fa0f03a8a13db849bfc4a5b10c19648e78baa2a22141fabd645b3d100730afb6fc615e0589abbdb83
|
7
|
+
data.tar.gz: 7439cb713a0696d19e129980d5269aa9d1af7a03b02b372888e57191b78ae78d5ea26337decf2561a1b4fff61f27cd3732e419362f59415c40c602eecff3fe26
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
sha256_seal (0.1.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
aw (0.1.1)
|
11
|
+
defi (1.1.3)
|
12
|
+
docile (1.3.1)
|
13
|
+
fix (0.17.1)
|
14
|
+
aw (~> 0.1.1)
|
15
|
+
defi (~> 1.1.3)
|
16
|
+
spectus (~> 3.0.6)
|
17
|
+
jaro_winkler (1.5.1)
|
18
|
+
json (2.1.0)
|
19
|
+
matchi (1.0.2)
|
20
|
+
parallel (1.12.1)
|
21
|
+
parser (2.5.1.2)
|
22
|
+
ast (~> 2.4.0)
|
23
|
+
powerpack (0.1.2)
|
24
|
+
rainbow (3.0.0)
|
25
|
+
rake (12.3.1)
|
26
|
+
rubocop (0.58.2)
|
27
|
+
jaro_winkler (~> 1.5.1)
|
28
|
+
parallel (~> 1.10)
|
29
|
+
parser (>= 2.5, != 2.5.1.1)
|
30
|
+
powerpack (~> 0.1)
|
31
|
+
rainbow (>= 2.2.2, < 4.0)
|
32
|
+
ruby-progressbar (~> 1.7)
|
33
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
34
|
+
ruby-progressbar (1.10.0)
|
35
|
+
simplecov (0.16.1)
|
36
|
+
docile (~> 1.1)
|
37
|
+
json (>= 1.8, < 3)
|
38
|
+
simplecov-html (~> 0.10.0)
|
39
|
+
simplecov-html (0.10.2)
|
40
|
+
spectus (3.0.6)
|
41
|
+
aw (~> 0.1.1)
|
42
|
+
defi (~> 1.1.1)
|
43
|
+
matchi (~> 1.0.2)
|
44
|
+
unicode-display_width (1.4.0)
|
45
|
+
yard (0.9.16)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
bundler (~> 1.16)
|
52
|
+
fix (~> 0.17)
|
53
|
+
rake (~> 12.3)
|
54
|
+
rubocop (~> 0.58)
|
55
|
+
sha256_seal!
|
56
|
+
simplecov (~> 0.16)
|
57
|
+
yard (~> 0.9)
|
58
|
+
|
59
|
+
BUNDLED WITH
|
60
|
+
1.16.1
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# Sha256Seal
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'sha256_seal'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sha256_seal
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Sign values and verify signatures of values.
|
22
|
+
|
23
|
+
## Example
|
24
|
+
|
25
|
+
In the context of a Web application, CSRF tokens could be embedded in URLs.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
secret = 'secret'
|
29
|
+
|
30
|
+
value = '/~bob/.__SIGNATURE_HERE__/documents/'
|
31
|
+
field = '__SIGNATURE_HERE__'
|
32
|
+
|
33
|
+
builder = Sha256Seal::Builder.new(value, secret, field)
|
34
|
+
builder.signed_value # => "/~bob/.8aa1d38b5c16d077d5ac1360c8a6f0248419ff5a3e6dca28a3233894ddcdf3c4/documents/"
|
35
|
+
builder.signed_value? # => false
|
36
|
+
|
37
|
+
value = '/~bob/.8aa1d38b5c16d077d5ac1360c8a6f0248419ff5a3e6dca28a3233894ddcdf3c4/documents/'
|
38
|
+
field = '8aa1d38b5c16d077d5ac1360c8a6f0248419ff5a3e6dca28a3233894ddcdf3c4'
|
39
|
+
|
40
|
+
builder = Sha256Seal::Builder.new(value, secret, field)
|
41
|
+
builder.signed_value # => "/~bob/.8aa1d38b5c16d077d5ac1360c8a6f0248419ff5a3e6dca28a3233894ddcdf3c4/documents/"
|
42
|
+
builder.signed_value? # => true
|
43
|
+
```
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cyril/sha256_seal.rb.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
|
7
|
+
RuboCop::RakeTask.new
|
8
|
+
|
9
|
+
Rake::TestTask.new do |t|
|
10
|
+
t.verbose = true
|
11
|
+
t.warning = true
|
12
|
+
t.pattern = File.join('fix', '**', '*_fix.rb')
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :test do
|
16
|
+
task :coverage do
|
17
|
+
ENV['COVERAGE'] = 'true'
|
18
|
+
Rake::Task['test'].invoke
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
task default: %i[test]
|
data/VERSION.semver
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.4
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/sha256_seal.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'digest/sha2'
|
4
|
+
|
5
|
+
# Namespace for the Sha256Seal library.
|
6
|
+
module Sha256Seal
|
7
|
+
# Main class for the Sha256Seal library.
|
8
|
+
class Builder
|
9
|
+
attr_reader :value, :secret, :field
|
10
|
+
|
11
|
+
def initialize(value, secret, field)
|
12
|
+
@value = value.to_s
|
13
|
+
@secret = secret.to_s
|
14
|
+
@field = field.to_s
|
15
|
+
|
16
|
+
i = @value.scan(@field).length
|
17
|
+
|
18
|
+
raise ArgumentError, "#{i} #{@field.inspect} occurrences instead of 1." unless i.equal?(1)
|
19
|
+
end
|
20
|
+
|
21
|
+
def signed_value
|
22
|
+
value.gsub(field, signature)
|
23
|
+
end
|
24
|
+
|
25
|
+
def signed_value?
|
26
|
+
signature.eql?(field)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def signature
|
32
|
+
Digest::SHA256.hexdigest(salt_value)
|
33
|
+
end
|
34
|
+
|
35
|
+
def salt_value
|
36
|
+
value.gsub(field, secret)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/sha256_seal.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'sha256_seal'
|
5
|
+
spec.version = File.read('VERSION.semver').chomp
|
6
|
+
spec.authors = ['Cyril Kato']
|
7
|
+
spec.email = ['contact@cyril.email']
|
8
|
+
|
9
|
+
spec.summary = 'Seal device with SHA-256 hash function.'
|
10
|
+
spec.description = 'Seal device with SHA-256 hash function, for Ruby.'
|
11
|
+
spec.homepage = 'https://github.com/cyril/sha256_seal.rb'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
|
+
f.match(%r{^(fix)/})
|
16
|
+
end
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
22
|
+
spec.add_development_dependency 'fix', '~> 0.17'
|
23
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
24
|
+
spec.add_development_dependency 'rubocop', '~> 0.58'
|
25
|
+
spec.add_development_dependency 'simplecov', '~> 0.16'
|
26
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
27
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sha256_seal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Kato
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
11
|
date: 2018-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -100,7 +100,19 @@ email:
|
|
100
100
|
executables: []
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
|
-
files:
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".rubocop.yml"
|
106
|
+
- ".travis.yml"
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- VERSION.semver
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- lib/sha256_seal.rb
|
115
|
+
- sha256_seal.gemspec
|
104
116
|
homepage: https://github.com/cyril/sha256_seal.rb
|
105
117
|
licenses:
|
106
118
|
- MIT
|