dynarex-password 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/dynarex-password.rb +37 -0
- metadata +66 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
#Â!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: dynarex-password.rb
|
4
|
+
|
5
|
+
require 'dynarex'
|
6
|
+
|
7
|
+
class DynarexPassword
|
8
|
+
|
9
|
+
attr_reader :dynarex
|
10
|
+
|
11
|
+
def initialize()
|
12
|
+
|
13
|
+
@temp_list = []
|
14
|
+
@dynarex = Dynarex.new('codes/code(index,value)')
|
15
|
+
|
16
|
+
chars = (0..9).to_a + Array.new(7) + ('A'..'Z').to_a + Array.new(6) + ('a'..'z').to_a
|
17
|
+
@chars = (0..9).to_a + ('A'..'Z').to_a + ('a'..'z').to_a
|
18
|
+
|
19
|
+
chars.each do |char|
|
20
|
+
@dynarex.create index: char, value: get_random_chars(2) if char
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def save(filepath) @dynarex.save filepath, pretty: true end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def get_random_chars(size)
|
29
|
+
|
30
|
+
newpass = Array.new(rand(size)+1, '').map{@chars[rand(@chars.size)]}.join
|
31
|
+
|
32
|
+
# return the encryption providing it doesn't already exist in the lookup table.
|
33
|
+
return !@temp_list.include?(newpass) ? newpass : get_random_chars(size)
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynarex-password
|
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-05-04 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: dynarex
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files: []
|
34
|
+
|
35
|
+
files:
|
36
|
+
- lib/dynarex-password.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage:
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.5.2
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: dynarex-password
|
65
|
+
test_files: []
|
66
|
+
|