leetpassword 0.1.0
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.
- data/lib/leetpassword.rb +50 -0
- metadata +64 -0
data/lib/leetpassword.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: leetpassword.rb
|
4
|
+
|
5
|
+
require 'random-word'
|
6
|
+
|
7
|
+
class LeetPassword
|
8
|
+
|
9
|
+
def self.generate(max_len=nil, subs={i: '1', o: '0', e: '3'})
|
10
|
+
|
11
|
+
if max_len and max_len <= 6 then
|
12
|
+
raise "max length must be greater than 6 characters"
|
13
|
+
end
|
14
|
+
|
15
|
+
noun = RandomWord.nouns.next.gsub(/_/,'')
|
16
|
+
if max_len then
|
17
|
+
until noun.length >= 6 and noun.length <= max_len
|
18
|
+
noun = RandomWord.nouns.next.gsub(/_/,'')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
subs.each{|k,v| noun.gsub!(k.to_s,v)}
|
23
|
+
return noun if noun.length > 7
|
24
|
+
|
25
|
+
adj = RandomWord.adjs.next.gsub(/_/,'')
|
26
|
+
if max_len then
|
27
|
+
until adj.length >= 6 and adj.length <= max_len
|
28
|
+
adj = RandomWord.adjs.next.gsub(/_/,'')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
subs.each{|k,v| adj.gsub!(k.to_s,v)}
|
33
|
+
|
34
|
+
return adj if adj.length > 7
|
35
|
+
|
36
|
+
if max_len then
|
37
|
+
if (adj+noun).length <= max_len then
|
38
|
+
return adj + noun
|
39
|
+
else
|
40
|
+
LeetPassword.generate(max_len,subs)
|
41
|
+
end
|
42
|
+
else
|
43
|
+
return adj + noun
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
if __FILE__ == $0 then
|
49
|
+
RandomWord.generate
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: leetpassword
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- James Robertson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2012-09-07 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: random-word
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
description:
|
27
|
+
email:
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files: []
|
33
|
+
|
34
|
+
files:
|
35
|
+
- lib/leetpassword.rb
|
36
|
+
homepage:
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.23
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: leetpassword creates a password with 1 or 2 random leet words.
|
63
|
+
test_files: []
|
64
|
+
|