password_utils 0.1.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a36aecdd62517839fc750686c4feb24bb2f811d32d9e86238c468e4697abaf71
4
- data.tar.gz: f9e8c738b0fd74596716a45f8fd6e1d8a72cfb781250e545dabfe7eddff7f458
3
+ metadata.gz: d5c6dee713ac0c6f70895a2edc12e170b3d8299d3e567bb8c2776959571e706e
4
+ data.tar.gz: c6062090132c7583f3e422429d45b14a81e249f608107a15d879f30d5f728463
5
5
  SHA512:
6
- metadata.gz: ff7bd7f76f78a286ee88659d5f491780d6591e610295eda60bf67a078bdfcd63c7e331e510da923afd9c3281b3638619ab1e12d97606dae4ab58737e13b75713
7
- data.tar.gz: 3401ab9e705a82ddac6b4038c42ef4db07016a8c8ef8d06a5a08d031ba7c5b0d70d54164fab09d0c25594bb2c814c4ffd13ba1b7c2f3551d1abd0d5fe6cb80cb
6
+ metadata.gz: 8ec710b1f114f9f5d0595af04ed1533839bc7227953a0e978f7c417462b8a76afb6f0ad3bfc035c0a5b2f31356179619783a3fab399a19559e19b75fffc9be31
7
+ data.tar.gz: 82202510e74f6c84f500f81869a94c7ca5eb59d689642482747c3c43b910e17fdbf1c5ed23067311ae1eafc6930ec82340da4de75c3f224f2f7acc1c6c274454
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Run the default task
15
+ run: |
16
+ gem install bundler -v 2.2.3
17
+ bundle install
18
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ Style/StringLiterals:
2
+ Enabled: true
3
+ EnforcedStyle: double_quotes
4
+
5
+ Style/StringLiteralsInInterpolation:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Layout/LineLength:
10
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in password_utils.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 0.80"
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ password_utils (0.1.0)
5
+ bcrypt (~> 3.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ bcrypt (3.1.20)
12
+ diff-lcs (1.5.1)
13
+ parallel (1.26.3)
14
+ parser (3.3.5.0)
15
+ ast (~> 2.4.1)
16
+ racc
17
+ racc (1.8.1)
18
+ rainbow (3.1.1)
19
+ rake (13.2.1)
20
+ regexp_parser (2.9.2)
21
+ rexml (3.3.8)
22
+ rspec (3.13.0)
23
+ rspec-core (~> 3.13.0)
24
+ rspec-expectations (~> 3.13.0)
25
+ rspec-mocks (~> 3.13.0)
26
+ rspec-core (3.13.1)
27
+ rspec-support (~> 3.13.0)
28
+ rspec-expectations (3.13.3)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.13.0)
31
+ rspec-mocks (3.13.2)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.13.0)
34
+ rspec-support (3.13.1)
35
+ rubocop (0.93.1)
36
+ parallel (~> 1.10)
37
+ parser (>= 2.7.1.5)
38
+ rainbow (>= 2.2.2, < 4.0)
39
+ regexp_parser (>= 1.8)
40
+ rexml
41
+ rubocop-ast (>= 0.6.0)
42
+ ruby-progressbar (~> 1.7)
43
+ unicode-display_width (>= 1.4.0, < 2.0)
44
+ rubocop-ast (1.32.3)
45
+ parser (>= 3.3.1.0)
46
+ ruby-progressbar (1.13.0)
47
+ unicode-display_width (1.8.0)
48
+
49
+ PLATFORMS
50
+ x86_64-darwin-23
51
+
52
+ DEPENDENCIES
53
+ password_utils!
54
+ rake (~> 13.0)
55
+ rspec (~> 3.0)
56
+ rubocop (~> 0.80)
57
+
58
+ BUNDLED WITH
59
+ 2.2.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 riyandika
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
@@ -21,7 +21,17 @@ Or install it yourself as:
21
21
 
22
22
  ## Usage
23
23
 
24
- TODO: Write usage instructions here
24
+ ```ruby
25
+ require 'password_utils'
26
+
27
+ # Example usage
28
+ password = 'super_secret'
29
+ hashed_password = PasswordUtils.password_hash(password)
30
+
31
+ # Verify the password
32
+ puts PasswordUtils.password_verify('super_secret', hashed_password) # should return true
33
+ puts PasswordUtils.password_verify('wrong_password', hashed_password) # should return false
34
+ ```
25
35
 
26
36
  ## Development
27
37
 
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "password_utils"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PasswordUtils
4
+ VERSION = "0.1.1"
5
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "password_utils/version"
4
+ require "bcrypt"
5
+
6
+ # PasswordUtils provides functionality for hashing and verifying passwords using bcrypt.
7
+ # It includes methods to hash a password and verify if a given password matches the hash.
8
+ module PasswordUtils
9
+ class Error < StandardError; end
10
+
11
+ # Hashes the password using bcrypt
12
+ def self.password_hash(password, cost = 12)
13
+ BCrypt::Password.create(password, cost: cost)
14
+ end
15
+
16
+ # Verifies a password against a hash
17
+ def self.password_verify(password, password_hash)
18
+ BCrypt::Password.new(password_hash) == password
19
+ end
20
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/password_utils/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "password_utils"
7
+ spec.version = PasswordUtils::VERSION
8
+ spec.authors = ["riyandika"]
9
+ spec.email = ["riyandika.andhi@gmail.com"]
10
+
11
+ spec.summary = "ruby Password Utils"
12
+ spec.description = "inspired by php password_hash, implemented for ruby gems"
13
+ spec.homepage = "https://github.com/riyandika/password_utils"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/riyandika/password_utils"
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|.*\.gem)\z}) }
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ # Uncomment to register a new dependency of your gem
33
+ spec.add_dependency "bcrypt", "~> 3.1"
34
+
35
+ # For more information and examples about making a new gem, checkout our
36
+ # guide at: https://bundler.io/guides/creating_gem.html
37
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "password_utils"
4
+
5
+ RSpec.describe PasswordUtils do
6
+ let(:password) { "super_secret" }
7
+ let(:hashed_password) { PasswordUtils.password_hash(password) }
8
+
9
+ describe ".password_hash" do
10
+ it "generates a hash for the password" do
11
+ expect(hashed_password).to be_a(BCrypt::Password)
12
+ end
13
+ end
14
+
15
+ describe ".password_verify" do
16
+ it "returns true for a valid password" do
17
+ expect(PasswordUtils.password_verify(password, hashed_password)).to be true
18
+ end
19
+
20
+ it "returns false for an invalid password" do
21
+ expect(PasswordUtils.password_verify("wrong_password", hashed_password)).to be false
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "password_utils"
4
+
5
+ RSpec.configure do |config|
6
+ # Enable flags like --only-failures and --next-failure
7
+ config.example_status_persistence_file_path = ".rspec_status"
8
+
9
+ # Disable RSpec exposing methods globally on `Module` and `main`
10
+ config.disable_monkey_patching!
11
+
12
+ config.expect_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: password_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - riyandika
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: bcrypt
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3.1'
20
20
  type: :runtime
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: '0'
26
+ version: '3.1'
27
27
  description: inspired by php password_hash, implemented for ruby gems
28
28
  email:
29
29
  - riyandika.andhi@gmail.com
@@ -31,7 +31,22 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".github/workflows/main.yml"
35
+ - ".gitignore"
36
+ - ".rspec"
37
+ - ".rubocop.yml"
38
+ - Gemfile
39
+ - Gemfile.lock
40
+ - LICENSE.txt
34
41
  - README.md
42
+ - Rakefile
43
+ - bin/console
44
+ - bin/setup
45
+ - lib/password_utils.rb
46
+ - lib/password_utils/version.rb
47
+ - password_utils.gemspec
48
+ - spec/password_utils_spec.rb
49
+ - spec/spec_helper.rb
35
50
  homepage: https://github.com/riyandika/password_utils
36
51
  licenses:
37
52
  - MIT