h 2.2.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +10 -2
- data/.yardoc/complete +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/Gemfile +1 -0
- data/LICENSE.md +1 -1
- data/README.md +23 -15
- data/Rakefile +1 -1
- data/VERSION.semver +1 -1
- data/bin/console +7 -0
- data/bin/h +9 -7
- data/bin/setup +6 -0
- data/h.gemspec +5 -6
- data/lib/h.rb +11 -46
- data/test/test_h.rb +15 -23
- metadata +15 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b16434031f5b5e709a131a094e25065701e207c
|
4
|
+
data.tar.gz: 1c0e43f7f37fa7727007eaae29bffb7fa5d9c3ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f35d34fc2ea767ec2c23dff59ebead4b2e4c51d58e7b0f7c0d47146a5957ef951a2a60419db4a10706f3e60edc0f63f90d98e05a8658e9d0ca217ab750484669
|
7
|
+
data.tar.gz: ef42be5f74e5450381a4e50ce75a167f2411ab7f46eed24423a53bf93ea9bc3a7057592d06d0434692288817075dd69f1443a63c1869c3cdea5c7a5e30207bd3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.1
|
data/.travis.yml
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
language: ruby
|
2
|
-
|
2
|
+
sudo: false
|
3
|
+
cache: bundler
|
4
|
+
script: 'bundle exec rake test:coverage --trace'
|
5
|
+
before_install:
|
6
|
+
- gem install bundler
|
3
7
|
rvm:
|
4
|
-
- 2.0
|
8
|
+
- 2.0
|
9
|
+
- 2.1
|
10
|
+
- 2.2
|
5
11
|
- ruby-head
|
12
|
+
- jruby-head
|
13
|
+
- rbx-2
|
data/.yardoc/complete
ADDED
File without changes
|
data/.yardoc/objects/root.dat
CHANGED
Binary file
|
data/Gemfile
CHANGED
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
## Overview
|
4
4
|
|
5
|
-
Small tool that generates salted hashes, scented with the
|
5
|
+
Small tool that generates salted hashes, scented with the SHA-256 hash function.
|
6
6
|
|
7
7
|
## Why?
|
8
8
|
|
@@ -14,33 +14,41 @@ Small tool that generates salted hashes, scented with the SHA2 function.
|
|
14
14
|
|
15
15
|
## Configuration
|
16
16
|
|
17
|
-
H reads its configuration from the `~/.h` file at initialization.
|
17
|
+
H reads its configuration from the `~/.h` file at initialization.
|
18
|
+
This file, which should be readable by its owner only, have the salt value.
|
18
19
|
|
19
20
|
## Examples
|
20
21
|
|
21
22
|
Generate a digest from the system:
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
-q0zMnMSszj8D23a8aNJX_VYry9oSSLZ30XlHkmFt9I=
|
26
|
-
$ h secret 3
|
27
|
-
-q0
|
24
|
+
```sh
|
25
|
+
$ echo "my-secret" > ~/.h
|
28
26
|
|
29
|
-
|
27
|
+
$ h p@ssw0rd
|
28
|
+
ff665753fe1d26bd6a721760fe3b6623568a9c51962d6bfc9b7fc73d1f1c14d5
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
$ h シークレット
|
31
|
+
069f550ba39da8f87b0229ad5e3d75814c472b1c5a109ff236f9184f49fb3a25
|
32
|
+
```
|
33
|
+
|
34
|
+
Same operations, with Ruby:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require "h"
|
38
|
+
|
39
|
+
builder = H::Builder.new("my-secret")
|
40
|
+
|
41
|
+
builder.call("p@ssw0rd") # => ff665753fe1d26bd6a721760fe3b6623568a9c51962d6bfc9b7fc73d1f1c14d5
|
42
|
+
builder.call("シークレット") # => 069f550ba39da8f87b0229ad5e3d75814c472b1c5a109ff236f9184f49fb3a25
|
43
|
+
```
|
35
44
|
|
36
45
|
## Status
|
37
46
|
|
38
47
|
* [![Gem Version](https://badge.fury.io/rb/h.png)](http://badge.fury.io/rb/h)
|
39
48
|
* [![Build Status](https://secure.travis-ci.org/cyril/h.rb.png)](//travis-ci.org/cyril/h.rb)
|
40
49
|
* [![Dependency Status](https://gemnasium.com/cyril/h.rb.svg)](//gemnasium.com/cyril/h.rb)
|
41
|
-
* [![Inline docs](http://inch-ci.org/github/cyril/h.rb.png)](http://inch-ci.org/github/cyril/h.rb)
|
42
50
|
* ![](https://ruby-gem-downloads-badge.herokuapp.com/h?type=total)
|
43
51
|
|
44
|
-
|
52
|
+
***
|
45
53
|
|
46
|
-
Copyright (c) 2014 Cyril
|
54
|
+
Copyright (c) 2014 Cyril Kato, released under the [ISC license](LICENSE.md)
|
data/Rakefile
CHANGED
data/VERSION.semver
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/bin/console
ADDED
data/bin/h
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require_relative File.join
|
3
|
+
require_relative File.join('..', 'lib', 'h')
|
4
4
|
|
5
5
|
CONF_PATH = File.join(File.expand_path('~'), '.h')
|
6
6
|
|
@@ -16,10 +16,12 @@ unless File.exist?(CONF_PATH)
|
|
16
16
|
puts 'Done.'
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
secret = File.open(CONF_PATH)
|
20
|
+
.readlines
|
21
|
+
.fetch(0)
|
22
|
+
.chomp
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
24
|
+
builder = H::Builder.new(secret)
|
25
|
+
result = builder.call(ARGV[0])
|
26
|
+
|
27
|
+
puts result
|
data/bin/setup
ADDED
data/h.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'h'
|
3
3
|
spec.version = File.read('VERSION.semver')
|
4
|
-
spec.authors = ['Cyril
|
4
|
+
spec.authors = ['Cyril Kato']
|
5
5
|
spec.email = ['contact@cyril.email']
|
6
6
|
spec.homepage = 'https://github.com/cyril/h.rb'
|
7
7
|
spec.summary = 'Salted hashes tool'
|
8
|
-
spec.description = 'Small tool that generates salted hashes, scented '
|
8
|
+
spec.description = 'Small tool that generates salted hashes, scented ' \
|
9
9
|
'with the SHA2 function, for those who prefer to put ' \
|
10
10
|
'makeup on passwords rather than yield them to Manager™.'
|
11
11
|
spec.license = 'ISC'
|
@@ -15,9 +15,8 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.test_files = spec.files.grep(/^test\//)
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
|
18
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
19
|
-
spec.add_development_dependency 'fix', '~> 0.
|
20
|
-
spec.add_development_dependency 'rake', '~>
|
21
|
-
spec.add_development_dependency 'yard', '~> 0.8'
|
18
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
19
|
+
spec.add_development_dependency 'fix', '~> 0.17'
|
20
|
+
spec.add_development_dependency 'rake', '~> 12.1'
|
22
21
|
spec.add_development_dependency 'coveralls', '~> 0.8'
|
23
22
|
end
|
data/lib/h.rb
CHANGED
@@ -1,56 +1,21 @@
|
|
1
|
-
require 'digest'
|
1
|
+
require 'digest/sha2'
|
2
2
|
|
3
|
-
# Namespace and main entry point for the H library.
|
4
3
|
module H
|
5
|
-
|
6
|
-
|
7
|
-
# Initialize a H instance.
|
8
|
-
#
|
9
|
-
# @param static_key [String] a random data
|
10
|
-
#
|
11
|
-
# @return [H::Generator] instance
|
12
|
-
#
|
13
|
-
def initialize(static_key)
|
14
|
-
@static_key = static_key
|
15
|
-
end
|
4
|
+
class Builder
|
5
|
+
attr_reader :secret
|
16
6
|
|
17
|
-
|
18
|
-
|
19
|
-
# @param m [String] a message
|
20
|
-
# @param l [Fixnum] the length of the returned string
|
21
|
-
#
|
22
|
-
# @return [String] salted cryptographic hash.
|
23
|
-
#
|
24
|
-
# @api public
|
25
|
-
def input(m, l)
|
26
|
-
m += @static_key
|
27
|
-
d = cryptographic_hash(m)
|
28
|
-
truncate d, l
|
7
|
+
def initialize(secret)
|
8
|
+
@secret = secret.to_s
|
29
9
|
end
|
30
10
|
|
31
|
-
|
32
|
-
|
33
|
-
# Build a hash from +m+ message.
|
34
|
-
#
|
35
|
-
# @param m [String] a message
|
36
|
-
#
|
37
|
-
# @return [String] cryptographic hash.
|
38
|
-
#
|
39
|
-
# @api private
|
40
|
-
def cryptographic_hash(m)
|
41
|
-
::Digest::SHA256.base64digest(m).tr('+/', '-_')
|
11
|
+
def call(value)
|
12
|
+
::Digest::SHA256.hexdigest(salt(value.to_s))
|
42
13
|
end
|
43
14
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
#
|
49
|
-
# @return [String] truncated string.
|
50
|
-
#
|
51
|
-
# @api private
|
52
|
-
def truncate(str, lng)
|
53
|
-
str[0, lng]
|
15
|
+
private
|
16
|
+
|
17
|
+
def salt(value)
|
18
|
+
value + secret
|
54
19
|
end
|
55
20
|
end
|
56
21
|
end
|
data/test/test_h.rb
CHANGED
@@ -1,39 +1,31 @@
|
|
1
1
|
require_relative '_test_helper'
|
2
2
|
|
3
|
-
Fix.describe H::
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
on :input, '', 44 do
|
8
|
-
it { MUST Eql: 'rdOQxxmSfOy-3-HA7OrnqT2Pl2Y_I7Ojqsc1NwVP4sg=' }
|
3
|
+
Fix.describe H::Builder do
|
4
|
+
on :new, 'my-secret' do
|
5
|
+
on :call, nil do
|
6
|
+
it { MUST eql '186ef76e9d6a723ecb570d4d9c287487d001e5d35f7ed4a313350a407950318e' }
|
9
7
|
end
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
it { MUST Eql: 'LCoF25LqK6yFMRs6OoQoZEI4GV4-gR7vd1JZtbi8swA=' }
|
9
|
+
on :call, 'p@ssw0rd' do
|
10
|
+
it { MUST eql 'ff665753fe1d26bd6a721760fe3b6623568a9c51962d6bfc9b7fc73d1f1c14d5' }
|
14
11
|
end
|
15
12
|
|
16
|
-
|
17
|
-
|
18
|
-
it { MUST Eql: 'LCoF25Lq' }
|
13
|
+
on :call, 'シークレット' do
|
14
|
+
it { MUST eql '069f550ba39da8f87b0229ad5e3d75814c472b1c5a109ff236f9184f49fb3a25' }
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
on :input, 'p@ssw0rd', 44 do
|
26
|
-
it { MUST_NOT Eql: 'LCoF25LqK6yFMRs6OoQoZEI4GV4-gR7vd1JZtbi8swA=' }
|
18
|
+
on :new, nil do
|
19
|
+
on :call, nil do
|
20
|
+
it { MUST eql 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855' }
|
27
21
|
end
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
it { MUST Eql: '-q0zMnMSszj8D23a8aNJX_VYry9oSSLZ30XlHkmFt9I=' }
|
23
|
+
on :call, 'p@ssw0rd' do
|
24
|
+
it { MUST eql 'a075d17f3d453073853f813838c15b8023b8c487038436354fe599c3942e1f95' }
|
32
25
|
end
|
33
26
|
|
34
|
-
|
35
|
-
|
36
|
-
it { MUST Eql: '-q0' }
|
27
|
+
on :call, 'シークレット' do
|
28
|
+
it { MUST eql '2f1a3e825632d6d5c2085839b7d82e38d9e7435d5cafb1d38801db87335ba0dd' }
|
37
29
|
end
|
38
30
|
end
|
39
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: h
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Cyril
|
7
|
+
- Cyril Kato
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,56 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.15'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.15'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fix
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.17'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.17'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: yard
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.8'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.8'
|
54
|
+
version: '12.1'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: coveralls
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,7 +71,9 @@ description: Small tool that generates salted hashes, scented with the SHA2 func
|
|
85
71
|
email:
|
86
72
|
- contact@cyril.email
|
87
73
|
executables:
|
74
|
+
- console
|
88
75
|
- h
|
76
|
+
- setup
|
89
77
|
extensions: []
|
90
78
|
extra_rdoc_files: []
|
91
79
|
files:
|
@@ -94,6 +82,7 @@ files:
|
|
94
82
|
- ".ruby-version"
|
95
83
|
- ".travis.yml"
|
96
84
|
- ".yardoc/checksums"
|
85
|
+
- ".yardoc/complete"
|
97
86
|
- ".yardoc/object_types"
|
98
87
|
- ".yardoc/objects/root.dat"
|
99
88
|
- ".yardoc/proxy_types"
|
@@ -102,7 +91,9 @@ files:
|
|
102
91
|
- README.md
|
103
92
|
- Rakefile
|
104
93
|
- VERSION.semver
|
94
|
+
- bin/console
|
105
95
|
- bin/h
|
96
|
+
- bin/setup
|
106
97
|
- h.gemspec
|
107
98
|
- lib/h.rb
|
108
99
|
- test/_test_helper.rb
|
@@ -129,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
120
|
version: '0'
|
130
121
|
requirements: []
|
131
122
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.11
|
133
124
|
signing_key:
|
134
125
|
specification_version: 4
|
135
126
|
summary: Salted hashes tool
|
@@ -138,4 +129,3 @@ test_files:
|
|
138
129
|
- test/support.rb
|
139
130
|
- test/support/coverage.rb
|
140
131
|
- test/test_h.rb
|
141
|
-
has_rdoc:
|