h 1.0.1 → 1.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.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm ruby-1.9.2@h
File without changes
@@ -1,21 +1,19 @@
1
- h1. H
1
+ = H
2
2
 
3
- h2. Overview
3
+ == Overview
4
4
 
5
5
  Very small cryptographic tool that generates on-the-fly custom message digests,
6
6
  according to some parameters.
7
7
 
8
- h2. Why?
8
+ == Why?
9
9
 
10
10
  Because I prefer to put makeup on passwords rather than yield them to Manager™.
11
11
 
12
- h2. Installation
12
+ == Installation
13
13
 
14
- <pre>
15
14
  gem install h
16
- </pre>
17
15
 
18
- h2. Configuration
16
+ == Configuration
19
17
 
20
18
  H reads its configuration from the YAML <tt>~/.h</tt> file at initialization.
21
19
  This file, which should be readable by its owner only, has four parameters:
@@ -25,55 +23,45 @@ This file, which should be readable by its owner only, has four parameters:
25
23
  * Encryption: A cryptographic hash function in Ruby's Digest module.
26
24
  * Static key: Provides salted messages through concatenation.
27
25
 
28
- h2. Examples
26
+ == Examples
29
27
 
30
28
  Generate a digest from the system:
31
29
 
32
- <pre>
33
30
  $ h secret
34
31
  t3dpe24xie3y74t
35
- </pre>
36
32
 
37
33
  Because no configuration has been detected, this default file was created:
38
34
 
39
- <pre>
40
35
  $ cat ~/.h
41
36
  ---
42
37
  max_length: 15
43
38
  radix: 36
44
39
  encryption: SHA1
45
40
  static_key: foobar
46
- </pre>
47
41
 
48
42
  Same operation, from Ruby:
49
43
 
50
- <pre>
51
44
  irb(main):001:0> require "h"
52
45
  true
53
46
  irb(main):002:0> H::Generator.new.input "secret"
54
47
  "t3dpe24xie3y74t"
55
- </pre>
56
48
 
57
49
  To prevent your log display the message as a string, do not specify it at first.
58
50
 
59
- <pre>
60
51
  $ h
61
52
  Message: ******
62
53
  t3dpe24xie3y74t
63
- </pre>
64
54
 
65
55
  Example with the SHA2 cryptographic hash instead of SHA1, and a custom key:
66
56
 
67
- <pre>
68
57
  $ echo "{max_length: 15, radix: 36, encryption: SHA2, static_key: sun}" > ~/.h
69
58
  $ h secret
70
59
  5gumh4smv1iit23
71
- </pre>
72
60
 
73
61
  And now a useless test, with conventional parameters. You can Google the result.
74
62
 
75
- <pre>
76
63
  $ echo "{max_length: 40, radix: 16, encryption: SHA1, static_key: ''}" > ~/.h
77
64
  $ h "The quick brown fox jumps over the lazy dog"
78
65
  2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
79
- </pre>
66
+
67
+ Copyright (c) 2011 Cyril Wack, released under the ISC license
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'lib'
8
+ t.libs << 'test'
9
+ t.test_files = FileList["test/**/*_{helper,test}.rb"]
10
+ end
11
+
12
+ task :default => :test
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 1
3
+ :minor: 1
4
+ :patch: 1
data/h.gemspec CHANGED
@@ -1,21 +1,24 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "h/version"
1
+ # encoding: utf-8
4
2
 
5
3
  Gem::Specification.new do |s|
6
4
  s.name = "h"
7
- s.version = H::VERSION
5
+ s.version = Psych.load_file("VERSION.yml").values.join('.')
8
6
  s.platform = Gem::Platform::RUBY
9
7
  s.authors = ["Cyril Wack"]
10
8
  s.email = ["cyril@gosu.fr"]
11
9
  s.homepage = "http://github.com/cyril/h"
12
10
  s.summary = %q{Custom hash generator}
13
- s.description = %q{Very small cryptographic tool that generates custom message digests according to some parameters.}
11
+ s.description = %q{A quick tool for those who prefer to put makeup on passwords rather than yield them to Manager™}
14
12
 
15
- s.rubyforge_project = "h"
13
+ s.required_ruby_version = '>= 1.9.2'
16
14
 
17
- s.add_dependency('highline')
18
- s.add_dependency('psych')
15
+ s.rubyforge_project = 'h'
16
+
17
+ s.bindir = 'bin'
18
+ s.executables = ['h']
19
+
20
+ s.add_dependency 'highline'
21
+ s.add_dependency 'psych'
19
22
 
20
23
  s.files = `git ls-files`.split("\n")
21
24
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/lib/h.rb CHANGED
@@ -6,19 +6,20 @@ module H
6
6
  class Generator
7
7
  CONF_PATH = File.join(File.expand_path('~'), '.h')
8
8
 
9
- def initialize
9
+ def initialize(options = {})
10
10
  unless File.exists?(CONF_PATH)
11
11
  File.open(CONF_PATH, 'w') do |f|
12
12
  Psych.dump({ 'encryption' => 'SHA1',
13
- 'static_key' => 'foobar',
14
- 'max_length' => 15,
15
- 'radix' => 36 }, f)
13
+ 'static_key' => 'foobar',
14
+ 'max_length' => 15,
15
+ 'radix' => 36 }, f)
16
16
  end
17
17
 
18
18
  File.chmod(0600, CONF_PATH)
19
19
  end
20
20
 
21
21
  @params = Psych.load_file(CONF_PATH)
22
+ @params.update(options)
22
23
  @params.freeze
23
24
  end
24
25
 
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+
3
+ class HTest < MiniTest::Unit::TestCase
4
+ def setup
5
+ @h = H::Generator.new({ 'encryption' => 'SHA1',
6
+ 'static_key' => 'foobar',
7
+ 'max_length' => 15,
8
+ 'radix' => 36 })
9
+ @my_h = H::Generator.new({ 'encryption' => 'SHA2',
10
+ 'static_key' => 'sun',
11
+ 'max_length' => 15,
12
+ 'radix' => 36 })
13
+ @sha1 = H::Generator.new({ 'encryption' => 'SHA1',
14
+ 'static_key' => '',
15
+ 'max_length' => 40,
16
+ 'radix' => 16 })
17
+ end
18
+
19
+ def test_h
20
+ assert_equal @h.input('secret'), 't3dpe24xie3y74t'
21
+ assert_equal @my_h.input('secret'), '5gumh4smv1iit23'
22
+ assert_equal @sha1.input('The quick brown fox jumps over the lazy dog'),
23
+ '2fd4e1c67a2d28fced849ee1bb76e7391b93eb12'
24
+ end
25
+ end
@@ -0,0 +1,2 @@
1
+ require 'h'
2
+ require 'minitest/autorun'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-04-21 00:00:00.000000000 %:z
13
- default_executable:
12
+ date: 2011-04-23 00:00:00.000000000Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: highline
17
- requirement: &2157571020 !ruby/object:Gem::Requirement
16
+ requirement: &2153658560 !ruby/object:Gem::Requirement
18
17
  none: false
19
18
  requirements:
20
19
  - - ! '>='
@@ -22,10 +21,10 @@ dependencies:
22
21
  version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *2157571020
24
+ version_requirements: *2153658560
26
25
  - !ruby/object:Gem::Dependency
27
26
  name: psych
28
- requirement: &2157570600 !ruby/object:Gem::Requirement
27
+ requirement: &2153658100 !ruby/object:Gem::Requirement
29
28
  none: false
30
29
  requirements:
31
30
  - - ! '>='
@@ -33,9 +32,9 @@ dependencies:
33
32
  version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *2157570600
37
- description: Very small cryptographic tool that generates custom message digests according
38
- to some parameters.
35
+ version_requirements: *2153658100
36
+ description: A quick tool for those who prefer to put makeup on passwords rather than
37
+ yield them to Manager™
39
38
  email:
40
39
  - cyril@gosu.fr
41
40
  executables:
@@ -44,15 +43,17 @@ extensions: []
44
43
  extra_rdoc_files: []
45
44
  files:
46
45
  - .gitignore
46
+ - .rvmrc
47
47
  - Gemfile
48
- - LICENSE
49
- - README.textile
48
+ - ISC-LICENSE
49
+ - README.rdoc
50
50
  - Rakefile
51
+ - VERSION.yml
51
52
  - bin/h
52
53
  - h.gemspec
53
54
  - lib/h.rb
54
- - lib/h/version.rb
55
- has_rdoc: true
55
+ - test/h_test.rb
56
+ - test/test_helper.rb
56
57
  homepage: http://github.com/cyril/h
57
58
  licenses: []
58
59
  post_install_message:
@@ -64,7 +65,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - - ! '>='
66
67
  - !ruby/object:Gem::Version
67
- version: '0'
68
+ version: 1.9.2
68
69
  required_rubygems_version: !ruby/object:Gem::Requirement
69
70
  none: false
70
71
  requirements:
@@ -73,8 +74,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
74
  version: '0'
74
75
  requirements: []
75
76
  rubyforge_project: h
76
- rubygems_version: 1.6.2
77
+ rubygems_version: 1.7.2
77
78
  signing_key:
78
79
  specification_version: 3
79
80
  summary: Custom hash generator
80
- test_files: []
81
+ test_files:
82
+ - test/h_test.rb
83
+ - test/test_helper.rb
@@ -1,3 +0,0 @@
1
- module H
2
- VERSION = "1.0.1"
3
- end