randpass 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 +7 -0
- data/LICENSE +21 -0
- data/README.md +46 -0
- data/bin/randpass +14 -0
- data/lib/randpass/random.rb +41 -0
- data/lib/randpass/version.rb +5 -0
- data/lib/randpass.rb +8 -0
- data/randpass.gemspec +40 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9a815400cfb4c02a5d4fa1f8b1ff46f1b09d37233e03aa4972d040b11dbaf29c
|
4
|
+
data.tar.gz: 755cb66daeb5b6e9fe899daa0e79fe4dd2cd532fbdb919d24b5d66451387b673
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd1fb7172ac42c415ab542655b0171a8d610d20e215034f78777e9237a3d3d88161aa8b42f4a9f4c52515853e0c65cf839663d44b10ef9ff8b78b1ff7fe68810
|
7
|
+
data.tar.gz: 9dfdd7b36a6dde71d99bc044c74d23628c1adbf88a6fe5171001c0842486d817da53490a5ffd3162cdf105e03a449f4432b96ce0ed46103e7e77df1d2e344499
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 alx3dev
|
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
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Randpass
|
2
|
+
|
3
|
+
Create random password with ruby. Use `SecureRandom#base64` + few random special characters.
|
4
|
+
|
5
|
+
## How to install
|
6
|
+
|
7
|
+
- install from rubygems
|
8
|
+
```
|
9
|
+
gem install randpass
|
10
|
+
```
|
11
|
+
- download from github with ssh
|
12
|
+
```
|
13
|
+
git clone git@github.com:alx3dev/randpass \
|
14
|
+
cd randpass && bundle install
|
15
|
+
```
|
16
|
+
- download from github with https
|
17
|
+
```
|
18
|
+
git clone https://www.github.com/alx3dev/randpass \
|
19
|
+
cd randpass && bundle install
|
20
|
+
```
|
21
|
+
|
22
|
+
## How to use:
|
23
|
+
|
24
|
+
- use from terminal
|
25
|
+
```
|
26
|
+
# default 18 characters
|
27
|
+
randpass
|
28
|
+
=> 3!J_GApnCy4Mor1hMPbI?LhT
|
29
|
+
|
30
|
+
# or add number of characters as argument
|
31
|
+
randpass 30
|
32
|
+
=> zBv2BXVB/X2WJMqzSE%VRe#Sg!/0_wYpvJC1gyHU
|
33
|
+
|
34
|
+
# if you not install from rubygems, you need to run
|
35
|
+
bin/randpass
|
36
|
+
```
|
37
|
+
- use as library
|
38
|
+
```ruby
|
39
|
+
require 'randpass'
|
40
|
+
|
41
|
+
Randpass[20]
|
42
|
+
# or
|
43
|
+
Randpass.randpass 20
|
44
|
+
=> "0!ZNiAUZCbjo!#hHeX+XX$eAC=!p"
|
45
|
+
```
|
46
|
+
Randpass is a module, so you can include/extend it in your class, to call `randpass` method.
|
data/bin/randpass
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
# Generate random password with base64 and few random special characters
|
6
|
+
#
|
7
|
+
module Randpass
|
8
|
+
class << self
|
9
|
+
#
|
10
|
+
# Add special characters to base64 random string, and shuffle it
|
11
|
+
# @note Always shuffle #base64 if it has less than 16 chars, because they end with '=='
|
12
|
+
#
|
13
|
+
def [](number_of_chars = 18)
|
14
|
+
param = SecureRandom.base64(number_of_chars)
|
15
|
+
rand(5..10).times { param = add_special_chars(param) }
|
16
|
+
param.split('').shuffle.join
|
17
|
+
end
|
18
|
+
alias randpass []
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
# rubocop:disable Metrics/MethodLength
|
23
|
+
def add_special_chars(param)
|
24
|
+
# bigger number than options - we don't want
|
25
|
+
# same number of special chars each time
|
26
|
+
count = SecureRandom.random_number 15_000
|
27
|
+
char = case count
|
28
|
+
when 1...1000 then '_'
|
29
|
+
when 1000...2000 then '!'
|
30
|
+
when 2000...3000 then '#'
|
31
|
+
when 3000...4000 then '$'
|
32
|
+
when 4000...5000 then '%'
|
33
|
+
when 6000...7000 then '?'
|
34
|
+
else return param
|
35
|
+
end
|
36
|
+
param[rand(param.size)] = char
|
37
|
+
param
|
38
|
+
end
|
39
|
+
# rubocop:enable Metrics/MethodLength
|
40
|
+
end
|
41
|
+
end
|
data/lib/randpass.rb
ADDED
data/randpass.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './lib/randpass/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'randpass'
|
7
|
+
s.version = Randpass::VERSION
|
8
|
+
s.summary = 'Ruby random password generator'
|
9
|
+
s.description = <<~DESCRIPTION
|
10
|
+
Generate random password with SecureRandom#base64. Add random number
|
11
|
+
of random special characters, and shuffle it.
|
12
|
+
DESCRIPTION
|
13
|
+
|
14
|
+
s.license = 'MIT'
|
15
|
+
s.authors = 'alx3dev'
|
16
|
+
s.homepage = 'https://github.com/alx3dev/randpass'
|
17
|
+
|
18
|
+
s.bindir = 'bin'
|
19
|
+
s.require_paths = 'lib'
|
20
|
+
s.executables = 'randpass'
|
21
|
+
|
22
|
+
s.metadata['homepage_uri'] = 'https://github.com/alx3dev/randpass'
|
23
|
+
s.metadata['source_code_uri'] = 'https://github.com/alx3dev/randpass'
|
24
|
+
s.metadata['bug_tracker_uri'] = "#{s.homepage}/issues"
|
25
|
+
s.metadata['changelog_uri'] = "#{s.homepage}/changelog.md"
|
26
|
+
s.metadata['documentation_uri'] = "https://rubydoc.info/gems/#{s.name}/#{s.version}"
|
27
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
28
|
+
|
29
|
+
s.files = %w[ lib/randpass.rb
|
30
|
+
lib/randpass/version.rb
|
31
|
+
lib/randpass/random.rb
|
32
|
+
LICENSE
|
33
|
+
README.md
|
34
|
+
randpass.gemspec]
|
35
|
+
|
36
|
+
s.required_ruby_version = '>= 2.7', '< 3.2'
|
37
|
+
|
38
|
+
s.add_development_dependency 'bundler', '~> 2.3'
|
39
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: randpass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- alx3dev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-02-20 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: '2.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
description: |
|
42
|
+
Generate random password with SecureRandom#base64. Add random number
|
43
|
+
of random special characters, and shuffle it.
|
44
|
+
email:
|
45
|
+
executables:
|
46
|
+
- randpass
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- bin/randpass
|
53
|
+
- lib/randpass.rb
|
54
|
+
- lib/randpass/random.rb
|
55
|
+
- lib/randpass/version.rb
|
56
|
+
- randpass.gemspec
|
57
|
+
homepage: https://github.com/alx3dev/randpass
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata:
|
61
|
+
homepage_uri: https://github.com/alx3dev/randpass
|
62
|
+
source_code_uri: https://github.com/alx3dev/randpass
|
63
|
+
bug_tracker_uri: https://github.com/alx3dev/randpass/issues
|
64
|
+
changelog_uri: https://github.com/alx3dev/randpass/changelog.md
|
65
|
+
documentation_uri: https://rubydoc.info/gems/randpass/0.1.1
|
66
|
+
rubygems_mfa_required: 'true'
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.7'
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '3.2'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubygems_version: 3.3.6
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Ruby random password generator
|
89
|
+
test_files: []
|