password_generator_trigram 0.0.6
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/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/README.md~ +35 -0
- data/Rakefile +2 -0
- data/bin/pgt +15 -0
- data/example.rb +26 -0
- data/lib/array_trigram.rb +1380 -0
- data/lib/password_generator_trigram/version.rb +3 -0
- data/lib/password_generator_trigram.rb +56 -0
- data/password_generator_trigram.gemspec +23 -0
- metadata +86 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative 'array_trigram'
|
2
|
+
|
3
|
+
class PasswordGenerator
|
4
|
+
include ArrayTrigram
|
5
|
+
SYMBOLS_FOR_PASSWORD = "abcdefghijklmnopqrstuvwxyz"
|
6
|
+
|
7
|
+
def create_new (password_length)
|
8
|
+
output = ""
|
9
|
+
sum = 0
|
10
|
+
ranno = rand * 125_729.0
|
11
|
+
|
12
|
+
# First 3 symbols
|
13
|
+
0.upto(25) do |c1|
|
14
|
+
0.upto(25) do |c2|
|
15
|
+
0.upto(25) do |c3|
|
16
|
+
sum += TRIGRAM[c1][c2][c3]
|
17
|
+
if sum > ranno
|
18
|
+
output += SYMBOLS_FOR_PASSWORD[c1]
|
19
|
+
output += SYMBOLS_FOR_PASSWORD[c2]
|
20
|
+
output += SYMBOLS_FOR_PASSWORD[c3]
|
21
|
+
c1 = 25
|
22
|
+
c2 = 25
|
23
|
+
break
|
24
|
+
end
|
25
|
+
end
|
26
|
+
break if c2 == 25
|
27
|
+
end
|
28
|
+
break if c1 == 25
|
29
|
+
end
|
30
|
+
|
31
|
+
# Now do a random walk.
|
32
|
+
3.upto(password_length - 1) do |numberchar|
|
33
|
+
c1 = SYMBOLS_FOR_PASSWORD.index(output[numberchar-2])
|
34
|
+
c2 = SYMBOLS_FOR_PASSWORD.index(output[numberchar-1])
|
35
|
+
sum = 0
|
36
|
+
0.upto(25) do |c3|
|
37
|
+
sum += TRIGRAM[c1][c2][c3]
|
38
|
+
end
|
39
|
+
break if sum == 0
|
40
|
+
ranno = rand * sum
|
41
|
+
sum = 0
|
42
|
+
0.upto(25) do |c3|
|
43
|
+
sum += TRIGRAM[c1][c2][c3]
|
44
|
+
if sum > ranno
|
45
|
+
output += SYMBOLS_FOR_PASSWORD[c3]
|
46
|
+
break
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
return output
|
51
|
+
end
|
52
|
+
|
53
|
+
def is_number?(obj)
|
54
|
+
obj.to_s == obj.to_i.to_s
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'password_generator_trigram/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "password_generator_trigram"
|
8
|
+
spec.version = PasswordGeneratorTrigram::VERSION
|
9
|
+
spec.authors = ["Makvik"]
|
10
|
+
spec.email = ["storm.gman@mail.ru"]
|
11
|
+
spec.summary = "GPW - Generate pronounceable passwords. This program uses statistics on the frequency of three-letter sequences in English to generate passwords."
|
12
|
+
spec.description = "GPW - Generate pronounceable passwords. This program uses statistics on the frequency of three-letter sequences in English to generate passwords."
|
13
|
+
spec.homepage = "https://github.com/Makvik/password_generator_trigram"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: password_generator_trigram
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Makvik
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-05 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: GPW - Generate pronounceable passwords. This program uses statistics
|
42
|
+
on the frequency of three-letter sequences in English to generate passwords.
|
43
|
+
email:
|
44
|
+
- storm.gman@mail.ru
|
45
|
+
executables:
|
46
|
+
- pgt
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- README.md~
|
54
|
+
- Rakefile
|
55
|
+
- bin/pgt
|
56
|
+
- example.rb
|
57
|
+
- lib/array_trigram.rb
|
58
|
+
- lib/password_generator_trigram.rb
|
59
|
+
- lib/password_generator_trigram/version.rb
|
60
|
+
- password_generator_trigram.gemspec
|
61
|
+
homepage: https://github.com/Makvik/password_generator_trigram
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.6.8
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: GPW - Generate pronounceable passwords. This program uses statistics on the
|
85
|
+
frequency of three-letter sequences in English to generate passwords.
|
86
|
+
test_files: []
|