h 2.0.0 → 2.1.1
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 +0 -1
- data/Gemfile +0 -3
- data/{ISC-LICENSE.md → LICENSE.md} +0 -0
- data/README.md +21 -51
- data/VERSION.semver +1 -0
- data/bin/h +2 -2
- data/h.gemspec +5 -6
- data/lib/h.rb +27 -12
- data/test/_test_helper.rb +0 -2
- data/test/test_h.rb +11 -6
- metadata +9 -9
- data/.env.example +0 -1
- data/VERSION.yml +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c07dc8a1160801aa395ef4a00a614038c5ce47b3
|
4
|
+
data.tar.gz: a2cc31855430b3c748f052d940f18efba1aeb178
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f119cb301bca5c0245bc4ec16a28999730a509c250759c87a482becda3ef653c40704ce1bb859b0ab45779253159201ac1e478296004c123ab0a08f793068570
|
7
|
+
data.tar.gz: 5382479ddf4fd3cb89a31612ba1d1bb213953a64ec5fdd4168c5c42cda9ec4f1f7924705e8a584efa161904b25a533218ee6c347dcc94b276fdcdf17b60e9b38
|
data/Gemfile
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -1,79 +1,49 @@
|
|
1
|
-
H
|
2
|
-
=
|
1
|
+
# H
|
3
2
|
|
4
|
-
Overview
|
5
|
-
--------
|
3
|
+
## Overview
|
6
4
|
|
7
|
-
|
8
|
-
according to some parameters.
|
5
|
+
Small tool that generates salted hashes, scented with the SHA2 function.
|
9
6
|
|
10
|
-
Why?
|
11
|
-
----
|
7
|
+
## Why?
|
12
8
|
|
13
|
-
|
9
|
+
> I prefer to put makeup on passwords rather than yield them to Manager™.
|
14
10
|
|
15
|
-
Installation
|
16
|
-
------------
|
11
|
+
## Installation
|
17
12
|
|
18
13
|
$ gem install h
|
19
14
|
|
20
|
-
Configuration
|
21
|
-
-------------
|
15
|
+
## Configuration
|
22
16
|
|
23
|
-
H reads its configuration from the
|
24
|
-
This file, which should be readable by its owner only, has four parameters:
|
17
|
+
H reads its configuration from the `~/.h` file at initialization. This file, which should be readable by its owner only, have the salt value.
|
25
18
|
|
26
|
-
|
27
|
-
* Radix: The number of unique digits that compose message digests.
|
28
|
-
* Encryption: A cryptographic hash function in Ruby's Digest module.
|
29
|
-
* Static key: Provides salted messages through concatenation.
|
30
|
-
|
31
|
-
Examples
|
32
|
-
--------
|
19
|
+
## Examples
|
33
20
|
|
34
21
|
Generate a digest from the system:
|
35
22
|
|
36
|
-
$ h
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
$ cat ~/.h
|
42
|
-
---
|
43
|
-
max_length: 15
|
44
|
-
radix: 36
|
45
|
-
encryption: SHA1
|
46
|
-
static_key: foobar
|
23
|
+
$ echo "塩" > ~/.h
|
24
|
+
$ h シークレット
|
25
|
+
-q0zMnMSszj8D23a8aNJX_VYry9oSSLZ30XlHkmFt9I=
|
26
|
+
$ h secret 3
|
27
|
+
-q0
|
47
28
|
|
48
29
|
Same operation, from Ruby:
|
49
30
|
|
50
31
|
irb(main):001:0> require "h"
|
51
32
|
true
|
52
|
-
irb(main):002:0> H::Generator.new.input "
|
53
|
-
"
|
33
|
+
irb(main):002:0> H::Generator.new("塩").input "シークレット", 3
|
34
|
+
"-q0"
|
54
35
|
|
55
36
|
To prevent your log display the message as a string, do not specify it at first.
|
56
37
|
|
57
38
|
$ h
|
58
39
|
Message: ******
|
59
|
-
|
60
|
-
|
61
|
-
Example with the SHA2 cryptographic hash instead of SHA1, and a custom key:
|
40
|
+
-q0zMnMSszj8D23a8aNJX_VYry9oSSLZ30XlHkmFt9I=
|
62
41
|
|
63
|
-
|
64
|
-
$ h secret
|
65
|
-
5gumh4smv1iit23
|
66
|
-
|
67
|
-
And now a useless test, with conventional parameters. You can Google the result.
|
68
|
-
|
69
|
-
$ echo "{max_length: 40, radix: 16, encryption: SHA1, static_key: ''}" > ~/.h
|
70
|
-
$ h "The quick brown fox jumps over the lazy dog"
|
71
|
-
2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
|
72
|
-
|
73
|
-
Code Status
|
74
|
-
-----------
|
42
|
+
## Code Status
|
75
43
|
|
76
44
|
* [](http://travis-ci.org/cyril/h)
|
77
45
|
* [](https://gemnasium.com/cyril/h)
|
78
46
|
|
79
|
-
|
47
|
+
* * *
|
48
|
+
|
49
|
+
Copyright (c) 2014 Cyril Wack, released under the [ISC license](LICENSE.md)
|
data/VERSION.semver
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.1
|
data/bin/h
CHANGED
data/h.gemspec
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
require 'yaml'
|
4
|
-
|
5
3
|
Gem::Specification.new do |s|
|
6
4
|
s.name = 'h'
|
7
|
-
s.version =
|
5
|
+
s.version = File.read('VERSION.semver')
|
8
6
|
s.platform = Gem::Platform::RUBY
|
9
7
|
s.authors = ['Cyril Wack']
|
10
8
|
s.email = ['contact@cyril.io']
|
11
9
|
s.homepage = 'https://github.com/cyril/h'
|
12
|
-
s.summary = %q{
|
13
|
-
s.description = %q{
|
10
|
+
s.summary = %q{Salted hashes tool}
|
11
|
+
s.description = %q{Small tool that generates salted hashes, scented with the SHA2 function, for those who prefer to put makeup on passwords rather than yield them to Manager™.}
|
12
|
+
s.license = 'ISC'
|
14
13
|
|
15
14
|
s.rubyforge_project = 'h'
|
16
15
|
|
17
16
|
s.bindir = 'bin'
|
18
17
|
s.executables = ['h']
|
19
18
|
|
20
|
-
s.
|
19
|
+
s.add_runtime_dependency 'highline'
|
21
20
|
|
22
21
|
s.files = `git ls-files`.split("\n")
|
23
22
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/h.rb
CHANGED
@@ -1,33 +1,48 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
|
4
|
-
Bundler.require
|
5
|
-
|
6
1
|
require 'highline/import'
|
7
2
|
require 'digest'
|
8
|
-
require 'dotenv'
|
9
|
-
Dotenv.load
|
10
3
|
|
11
4
|
module H
|
12
5
|
class Generator
|
6
|
+
CONF_PATH = File.join(File.expand_path('~'), '.h')
|
7
|
+
|
8
|
+
def initialize(static_key = nil)
|
9
|
+
@static_key = if static_key
|
10
|
+
static_key
|
11
|
+
else
|
12
|
+
unless File.exists?(CONF_PATH)
|
13
|
+
print "Creating #{CONF_PATH} file... "
|
14
|
+
|
15
|
+
File.open(CONF_PATH, 'w') do |f|
|
16
|
+
f.write('secret')
|
17
|
+
end
|
18
|
+
|
19
|
+
File.chmod(0600, CONF_PATH)
|
20
|
+
|
21
|
+
puts "Done."
|
22
|
+
end
|
23
|
+
|
24
|
+
File.open(CONF_PATH).readlines.first.chomp
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
13
28
|
def prompt
|
14
29
|
input ask('Message: ') {|q| q.echo = '*' }
|
15
30
|
end
|
16
31
|
|
17
32
|
def input(m, l = 44)
|
18
|
-
m = m +
|
33
|
+
m = m + @static_key
|
19
34
|
d = cryptographic_hash(m)
|
20
35
|
truncate d, l
|
21
36
|
end
|
22
37
|
|
23
38
|
protected
|
24
39
|
|
25
|
-
def cryptographic_hash(
|
26
|
-
Digest::SHA2.base64digest(
|
40
|
+
def cryptographic_hash(m)
|
41
|
+
Digest::SHA2.base64digest(m).tr('+/', '-_')
|
27
42
|
end
|
28
43
|
|
29
|
-
def truncate(
|
30
|
-
|
44
|
+
def truncate(str, lng)
|
45
|
+
str[0, lng]
|
31
46
|
end
|
32
47
|
end
|
33
48
|
end
|
data/test/_test_helper.rb
CHANGED
data/test/test_h.rb
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
require_relative '_test_helper'
|
2
4
|
|
3
5
|
class HTest < MiniTest::Unit::TestCase
|
4
|
-
def setup
|
5
|
-
@h = H::Generator.new
|
6
|
-
end
|
7
|
-
|
8
6
|
def test_h
|
9
|
-
|
10
|
-
|
7
|
+
@h = H::Generator.new('my-salt')
|
8
|
+
|
9
|
+
assert_equal @h.input('p@ssw0rd'), 'LCoF25LqK6yFMRs6OoQoZEI4GV4-gR7vd1JZtbi8swA='
|
10
|
+
assert_equal @h.input('p@ssw0rd', 8), 'LCoF25Lq'
|
11
|
+
|
12
|
+
@h = H::Generator.new('塩')
|
13
|
+
|
14
|
+
assert_equal @h.input('シークレット'), '-q0zMnMSszj8D23a8aNJX_VYry9oSSLZ30XlHkmFt9I='
|
15
|
+
assert_equal @h.input('シークレット', 3), '-q0'
|
11
16
|
end
|
12
17
|
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: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cyril Wack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -24,8 +24,8 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description:
|
28
|
-
yield them to Manager
|
27
|
+
description: Small tool that generates salted hashes, scented with the SHA2 function,
|
28
|
+
for those who prefer to put makeup on passwords rather than yield them to Manager™.
|
29
29
|
email:
|
30
30
|
- contact@cyril.io
|
31
31
|
executables:
|
@@ -33,22 +33,22 @@ executables:
|
|
33
33
|
extensions: []
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
|
-
- ".env.example"
|
37
36
|
- ".gitignore"
|
38
37
|
- ".ruby-version"
|
39
38
|
- ".travis.yml"
|
40
39
|
- Gemfile
|
41
|
-
-
|
40
|
+
- LICENSE.md
|
42
41
|
- README.md
|
43
42
|
- Rakefile
|
44
|
-
- VERSION.
|
43
|
+
- VERSION.semver
|
45
44
|
- bin/h
|
46
45
|
- h.gemspec
|
47
46
|
- lib/h.rb
|
48
47
|
- test/_test_helper.rb
|
49
48
|
- test/test_h.rb
|
50
49
|
homepage: https://github.com/cyril/h
|
51
|
-
licenses:
|
50
|
+
licenses:
|
51
|
+
- ISC
|
52
52
|
metadata: {}
|
53
53
|
post_install_message:
|
54
54
|
rdoc_options: []
|
@@ -69,7 +69,7 @@ rubyforge_project: h
|
|
69
69
|
rubygems_version: 2.2.2
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
|
-
summary:
|
72
|
+
summary: Salted hashes tool
|
73
73
|
test_files:
|
74
74
|
- test/_test_helper.rb
|
75
75
|
- test/test_h.rb
|
data/.env.example
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
STATIC_KEY=secret
|
data/VERSION.yml
DELETED