h 4.0.0 → 4.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c0ae3b158ff41bdca434eaaacd48a2c2e9ebd79d
4
- data.tar.gz: e5019914b6044ea05a060636a8778e9d0c128640
2
+ SHA256:
3
+ metadata.gz: 74221be01ab8dc401a378861ec34dc6503137000783ec47bb1f1ea3f00cf2307
4
+ data.tar.gz: baa11435f26bd735ab88248180a95e63fed3eb48e6b373121d4de84a0adee389
5
5
  SHA512:
6
- metadata.gz: e9fc33a412e2a2a90f1780c4749c4b7e1fe9a7b547983d40e1685a2ee49afa7f1e40d405fe4e89fff04d6b5b44336c1b578a6341e7cbf73a8dca7d05b323f752
7
- data.tar.gz: 45bab5002bd34e05e5116b90bca05f6416744cd75063ebee381bc241441dc3f676f4e1b1824523f350b176545ce29b92e509b55b285ed2bf7910c3e5a6abf011
6
+ metadata.gz: 16aad9027f3feb7e62c3f6a5b26bc08b2d8dc7e9bacaf6a1b546d43475d01b48b575488fed5b4f31c7894b367e381d0636342c84198691240bd68a5d25b9034e
7
+ data.tar.gz: db986b971cf607961ca5696d0bffa240a89e95609781dc87070e1b2bcd751e075b5a8ecc204f71cb58fe581db166a6ecd2e6e49c7a7ef4450ab9f4bd86c00429
data/LICENSE.md CHANGED
@@ -1,13 +1,21 @@
1
- Copyright (c) 2011, Cyril Kato
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any
4
- purpose with or without fee is hereby granted, provided that the above
5
- copyright notice and this permission notice appear in all copies.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2011-2025 Cyril Kato
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # H
1
+ # H.rb
2
2
 
3
3
  ## Overview
4
4
 
@@ -14,23 +14,35 @@ Small tool that generates salted hashes, scented with the SHA-256 hash 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
18
  This file, which should be readable by its owner only, have the salt value.
19
19
 
20
20
  ## Examples
21
21
 
22
+ Settings:
23
+
24
+ ```sh
25
+ echo "my-secret" > ~/.h
26
+ ```
27
+
22
28
  Generate a digest from the system:
23
29
 
24
30
  ```sh
25
- $ echo "my-secret" > ~/.h
31
+ h p@ssw0rd
32
+ ```
33
+
34
+ Result:
26
35
 
27
- $ h p@ssw0rd
28
- +KsELdbw7gM0e2lQsnCskf1albEXgl9MtXgrmvYkIaM=
36
+ > `+KsELdbw7gM0e2lQsnCskf1albEXgl9MtXgrmvYkIaM=`
29
37
 
30
- $ h シークレット
31
- NaNvnGJGWWzzU9DlRSRKZQQER1/9/libXrrghMgBWbU=
38
+ ```sh
39
+ h シークレット
32
40
  ```
33
41
 
42
+ Result:
43
+
44
+ > `NaNvnGJGWWzzU9DlRSRKZQQER1/9/libXrrghMgBWbU=`
45
+
34
46
  Same operations, with Ruby:
35
47
 
36
48
  ```ruby
@@ -38,17 +50,42 @@ require "h"
38
50
 
39
51
  builder = H::Builder.new("my-secret")
40
52
 
41
- builder.call("p@ssw0rd") # => +KsELdbw7gM0e2lQsnCskf1albEXgl9MtXgrmvYkIaM=
42
- builder.call("シークレット") # => NaNvnGJGWWzzU9DlRSRKZQQER1/9/libXrrghMgBWbU=
53
+ builder.call("p@ssw0rd") # => "+KsELdbw7gM0e2lQsnCskf1albEXgl9MtXgrmvYkIaM="
54
+ builder.call("シークレット") # => "NaNvnGJGWWzzU9DlRSRKZQQER1/9/libXrrghMgBWbU="
55
+ ```
56
+
57
+ ## Alternative Implementations
58
+
59
+ Shell script implementations are available in the `alternatives/` directory:
60
+
61
+ ### Bash Implementation
62
+
63
+ A POSIX-compliant version focusing on compatibility and security:
64
+
65
+ ```sh
66
+ ./alternatives/bash/h.sh p@ssw0rd
67
+ ```
68
+
69
+ Result:
70
+
71
+ > `+KsELdbw7gM0e2lQsnCskf1albEXgl9MtXgrmvYkIaM=`
72
+
73
+ ### Zsh Implementation
74
+
75
+ A modern implementation using ZSH-specific features:
76
+
77
+ ```sh
78
+ ./alternatives/zsh/h.zsh p@ssw0rd
43
79
  ```
44
80
 
45
- ## Status
81
+ Result:
46
82
 
47
- * [![Gem Version](https://badge.fury.io/rb/h.png)](http://badge.fury.io/rb/h)
48
- * [![Build Status](https://secure.travis-ci.org/cyril/h.rb.png)](//travis-ci.org/cyril/h.rb)
49
- * [![Dependency Status](https://gemnasium.com/cyril/h.rb.svg)](//gemnasium.com/cyril/h.rb)
50
- * ![](https://ruby-gem-downloads-badge.herokuapp.com/h?type=total)
83
+ > `+KsELdbw7gM0e2lQsnCskf1albEXgl9MtXgrmvYkIaM=`
51
84
 
52
- ***
85
+ Both shell implementations:
86
+ - Use the same configuration file (`~/.h`)
87
+ - Provide identical output format
88
+ - Enforce secure file permissions
89
+ - Handle cleanup automatically
53
90
 
54
- Copyright (c) 2014 Cyril Kato, released under the [ISC license](LICENSE.md)
91
+ See individual READMEs in the `alternatives/` directory for implementation details.
data/bin/h CHANGED
@@ -1,19 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require_relative File.join('..', 'lib', 'h')
4
+ require_relative File.join("..", "lib", "h")
4
5
 
5
- CONF_PATH = File.join(File.expand_path('~'), '.h')
6
+ CONF_PATH = File.join(File.expand_path("~"), ".h")
6
7
 
7
8
  unless File.exist?(CONF_PATH)
8
9
  print "Creating #{CONF_PATH} file... "
9
10
 
10
- File.open(CONF_PATH, 'w') do |f|
11
- f.write('secret')
12
- end
11
+ File.write(CONF_PATH, "secret")
13
12
 
14
- File.chmod(0600, CONF_PATH)
13
+ File.chmod(600, CONF_PATH)
15
14
 
16
- puts 'Done.'
15
+ puts "Done."
17
16
  end
18
17
 
19
18
  secret = File.open(CONF_PATH)
data/lib/h.rb CHANGED
@@ -1,13 +1,28 @@
1
- require 'digest/sha2'
1
+ # frozen_string_literal: true
2
2
 
3
+ require "digest/sha2"
4
+
5
+ # H module provides secure password hashing functionality
6
+ # @example
7
+ # builder = H::Builder.new("my-secret-salt")
8
+ # hash = builder.call("my-password")
3
9
  module H
10
+ # Builder handles the creation of salted password hashes using SHA-256
4
11
  class Builder
12
+ # @return [String] the secret salt used for hashing
5
13
  attr_reader :secret
6
14
 
15
+ # Initialize a new Builder with a secret salt
16
+ # @param secret [Object] the salt to use for hashing (will be converted to String)
7
17
  def initialize(secret)
8
- @secret = secret
18
+ @secret = String(secret)
19
+
20
+ freeze
9
21
  end
10
22
 
23
+ # Generate a salted hash of the provided value
24
+ # @param value [String] the value to hash
25
+ # @return [String] Base64 encoded SHA-256 hash
11
26
  def call(value)
12
27
  ::Digest::SHA256.base64digest("#{value}++#{secret}")
13
28
  end
metadata CHANGED
@@ -1,110 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Kato
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2017-10-25 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.15'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.15'
27
- - !ruby/object:Gem::Dependency
28
- name: fix
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '0.17'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '0.17'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '12.1'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '12.1'
55
- - !ruby/object:Gem::Dependency
56
- name: coveralls
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'
69
- description: Small tool that generates salted hashes, scented with the SHA2 function,
10
+ date: 2025-01-07 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: 'Small tool that generates salted hashes, scented with the SHA2 function,
70
13
  for those who prefer to put makeup on passwords rather than yield them to Manager™.
71
- email:
72
- - contact@cyril.email
14
+
15
+ '
16
+ email: contact@cyril.email
73
17
  executables:
74
- - console
75
18
  - h
76
- - setup
77
19
  extensions: []
78
20
  extra_rdoc_files: []
79
21
  files:
80
- - ".coveralls.yml"
81
- - ".gitignore"
82
- - ".ruby-version"
83
- - ".travis.yml"
84
- - ".yardoc/checksums"
85
- - ".yardoc/complete"
86
- - ".yardoc/object_types"
87
- - ".yardoc/objects/root.dat"
88
- - ".yardoc/proxy_types"
89
- - Gemfile
90
22
  - LICENSE.md
91
23
  - README.md
92
- - Rakefile
93
- - VERSION.semver
94
- - bin/console
95
24
  - bin/h
96
- - bin/setup
97
- - h.gemspec
98
25
  - lib/h.rb
99
- - test/_test_helper.rb
100
- - test/support.rb
101
- - test/support/coverage.rb
102
- - test/test_h.rb
103
26
  homepage: https://github.com/cyril/h.rb
104
27
  licenses:
105
- - ISC
106
- metadata: {}
107
- post_install_message:
28
+ - MIT
29
+ metadata:
30
+ rubygems_mfa_required: 'true'
108
31
  rdoc_options: []
109
32
  require_paths:
110
33
  - lib
@@ -112,20 +35,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
35
  requirements:
113
36
  - - ">="
114
37
  - !ruby/object:Gem::Version
115
- version: '0'
38
+ version: 3.1.0
116
39
  required_rubygems_version: !ruby/object:Gem::Requirement
117
40
  requirements:
118
41
  - - ">="
119
42
  - !ruby/object:Gem::Version
120
43
  version: '0'
121
44
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.6.11
124
- signing_key:
45
+ rubygems_version: 3.6.2
125
46
  specification_version: 4
126
47
  summary: Salted hashes tool
127
- test_files:
128
- - test/_test_helper.rb
129
- - test/support.rb
130
- - test/support/coverage.rb
131
- - test/test_h.rb
48
+ test_files: []
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci
data/.gitignore DELETED
@@ -1,5 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
5
- /coverage/
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.4.1
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- script: 'bundle exec rake test:coverage --trace'
5
- before_install:
6
- - gem install bundler
7
- rvm:
8
- - 2.0
9
- - 2.1
10
- - 2.2
11
- - ruby-head
12
- - jruby-head
13
- - rbx-2
data/.yardoc/checksums DELETED
@@ -1 +0,0 @@
1
- lib/h.rb 8584911e99ca0561a69fe42a5228a2082f705432
data/.yardoc/complete DELETED
File without changes
data/.yardoc/object_types DELETED
Binary file
Binary file
data/.yardoc/proxy_types DELETED
Binary file
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/Rakefile DELETED
@@ -1,16 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new do |t|
5
- t.verbose = true
6
- t.warning = true
7
- end
8
-
9
- namespace :test do
10
- task :coverage do
11
- ENV['COVERAGE'] = 'true'
12
- Rake::Task['test'].invoke
13
- end
14
- end
15
-
16
- task default: %i[test]
data/VERSION.semver DELETED
@@ -1 +0,0 @@
1
- 4.0.0
data/bin/console DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'bundler/setup'
4
- require 'h'
5
-
6
- require 'irb'
7
- IRB.start
data/bin/setup DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/bash
2
-
3
- set -euo pipefail
4
- IFS=$'\n\t'
5
-
6
- bundle install
data/h.gemspec DELETED
@@ -1,22 +0,0 @@
1
- Gem::Specification.new do |spec|
2
- spec.name = 'h'
3
- spec.version = File.read('VERSION.semver')
4
- spec.authors = ['Cyril Kato']
5
- spec.email = ['contact@cyril.email']
6
- spec.homepage = 'https://github.com/cyril/h.rb'
7
- spec.summary = 'Salted hashes tool'
8
- spec.description = 'Small tool that generates salted hashes, scented ' \
9
- 'with the SHA2 function, for those who prefer to put ' \
10
- 'makeup on passwords rather than yield them to Manager™.'
11
- spec.license = 'ISC'
12
-
13
- spec.files = `git ls-files -z`.split("\x0")
14
- spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
15
- spec.test_files = spec.files.grep(/^test\//)
16
- spec.require_paths = ['lib']
17
-
18
- spec.add_development_dependency 'bundler', '~> 1.15'
19
- spec.add_development_dependency 'fix', '~> 0.17'
20
- spec.add_development_dependency 'rake', '~> 12.1'
21
- spec.add_development_dependency 'coveralls', '~> 0.8'
22
- end
data/test/_test_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- require_relative 'support'
2
- require_relative File.join '..', 'lib', 'h'
3
- require 'fix'
@@ -1,9 +0,0 @@
1
- require 'simplecov'
2
- require 'coveralls'
3
-
4
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
- SimpleCov::Formatter::HTMLFormatter,
6
- Coveralls::SimpleCov::Formatter
7
- ]
8
-
9
- SimpleCov.start
data/test/support.rb DELETED
@@ -1,3 +0,0 @@
1
- Dir[File.join File.dirname(__FILE__), 'support', '**' '*.rb'].each do |filename|
2
- require_relative filename
3
- end
data/test/test_h.rb DELETED
@@ -1,31 +0,0 @@
1
- require_relative '_test_helper'
2
-
3
- Fix.describe H::Builder do
4
- on :new, 'my-secret' do
5
- on :call, nil do
6
- it { MUST eql 'NKLNPIzInF96PBmMCqZR1jFaIoHn9c1y0n8jtMam4cs=' }
7
- end
8
-
9
- on :call, 'p@ssw0rd' do
10
- it { MUST eql '+KsELdbw7gM0e2lQsnCskf1albEXgl9MtXgrmvYkIaM=' }
11
- end
12
-
13
- on :call, 'シークレット' do
14
- it { MUST eql 'NaNvnGJGWWzzU9DlRSRKZQQER1/9/libXrrghMgBWbU=' }
15
- end
16
- end
17
-
18
- on :new, nil do
19
- on :call, nil do
20
- it { MUST eql 'z8DAYHozgPeXU0azDBSvgoT1ST2XgbDthH9JnwG0do4=' }
21
- end
22
-
23
- on :call, 'p@ssw0rd' do
24
- it { MUST eql 'M1YbuYA4RzKHPYXaUm/GH49wLTA8JOu4WCGbt8QVOrE=' }
25
- end
26
-
27
- on :call, 'シークレット' do
28
- it { MUST eql 'jBU9DIODvHm1tTS7LHHJ1fM/SD3dIgwbYs8sXQkttJw=' }
29
- end
30
- end
31
- end