password_kun 0.2.3
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/lib/password_kun.rb +72 -0
- metadata +59 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f3f34c76b8e9fcf3e28e73c9cb6eebc97821c6333e392971da71b70adbfcee5c
|
|
4
|
+
data.tar.gz: 56f7bf37c78379529664d03c14fd69d5a1f00eb0231e380c0435036a2757ee60
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 610a00fcaaf1906b28bed80939f6be51c0d5365d97df2e297351f3f53153bee7205f4f135f0acff85c0a2a3992b93f469c0c2bf7c1767b7e5af77ea7fdf86802
|
|
7
|
+
data.tar.gz: 269ea67aaceae4b7e895acb95a5254bd1164ecbf1a8884e96864e771d83a26dcdb992567aa0f2672b6f12b93b90383fc723b50f5d5a9869912b10fb673db8d82
|
data/lib/password_kun.rb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require './lib/keyboard_layout'
|
|
2
|
+
require './lib/pattern'
|
|
3
|
+
require 'httparty'
|
|
4
|
+
KB = KeyboardLayout
|
|
5
|
+
DIRECTIONS = [
|
|
6
|
+
[0, -1],
|
|
7
|
+
[1, -1],
|
|
8
|
+
[1, 0],
|
|
9
|
+
[0, 1],
|
|
10
|
+
[-1, 1],
|
|
11
|
+
[-1, 0],
|
|
12
|
+
[0, 0]
|
|
13
|
+
].freeze
|
|
14
|
+
WORD_SRC = 'https://randomword.com'.freeze
|
|
15
|
+
FIND_WORD_PATTERN = %r{\w+(?=<\/div>)}.freeze
|
|
16
|
+
# instance to configure password options
|
|
17
|
+
class PasswordKun
|
|
18
|
+
def initialize(options = {})
|
|
19
|
+
@length = options[:length] || (8..16)
|
|
20
|
+
@kb_layout = options[:kb_layout] || KB.standard
|
|
21
|
+
@has_number = options[:has_number] || true
|
|
22
|
+
@has_layout = options[:has_layout] || true
|
|
23
|
+
@has_uppercase = options[:has_uppercase] || false
|
|
24
|
+
@has_word = options[:has_word] || true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def make_password(amount = 4)
|
|
28
|
+
Array.new(amount).map do
|
|
29
|
+
process_password.shuffle.join('-')
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def process_password
|
|
36
|
+
left_len = rand(@length)
|
|
37
|
+
if @has_word
|
|
38
|
+
process_with_word(left_len, [])
|
|
39
|
+
else
|
|
40
|
+
process_without_word(left_len, [])
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def process_with_word(left_len, pw_que)
|
|
45
|
+
word_p = Pattern.word(WORD_SRC, FIND_WORD_PATTERN)
|
|
46
|
+
loop do
|
|
47
|
+
break if word_p.length <= left_len - 6
|
|
48
|
+
|
|
49
|
+
word_p = Pattern.word(WORD_SRC, FIND_WORD_PATTERN)
|
|
50
|
+
end
|
|
51
|
+
pw_que << word_p
|
|
52
|
+
left_len -= word_p.length
|
|
53
|
+
left_len, pw_que = process_number(left_len, pw_que) if @has_number
|
|
54
|
+
pw_que = process_layout(left_len, pw_que) if @has_layout
|
|
55
|
+
pw_que
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def process_without_word
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def process_number(left_len, pw_que)
|
|
62
|
+
number_len = rand(2..left_len - 3)
|
|
63
|
+
number_p = Pattern.number(number_len)
|
|
64
|
+
left_len -= number_p.length
|
|
65
|
+
pw_que << number_p
|
|
66
|
+
[left_len, pw_que]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def process_layout(left_len, pw_que)
|
|
70
|
+
pw_que << Pattern.layout(left_len, @kb_layout)
|
|
71
|
+
end
|
|
72
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: password_kun
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Azuma Shibada
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-01-26 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: httparty
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
description: With numbers, random words based on keyboard layout or dictionary, you
|
|
28
|
+
can generate password that don't take you weeks to remember but still secure enough
|
|
29
|
+
:)
|
|
30
|
+
email: 0711kps@gmail.com
|
|
31
|
+
executables: []
|
|
32
|
+
extensions: []
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- lib/password_kun.rb
|
|
36
|
+
homepage: https://github.com/0711kps/password_kun
|
|
37
|
+
licenses:
|
|
38
|
+
- MIT
|
|
39
|
+
metadata: {}
|
|
40
|
+
post_install_message:
|
|
41
|
+
rdoc_options: []
|
|
42
|
+
require_paths:
|
|
43
|
+
- lib
|
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '2.6'
|
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '3'
|
|
54
|
+
requirements: []
|
|
55
|
+
rubygems_version: 3.0.1
|
|
56
|
+
signing_key:
|
|
57
|
+
specification_version: 4
|
|
58
|
+
summary: Human-Friendly password generator.
|
|
59
|
+
test_files: []
|