sixarm_ruby_password_text 1.2.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.
- data.tar.gz.sig +1 -0
- data/LICENSE.txt +12 -0
- data/README.rdoc +28 -0
- data/lib/sixarm_ruby_password_text.rb +110 -0
- data/test/sixarm_ruby_password_text_test.rb +44 -0
- metadata +101 -0
- metadata.gz.sig +1 -0
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
���"�O策
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
LICENSE
|
2
|
+
|
3
|
+
You may choose any of these licenses:
|
4
|
+
|
5
|
+
- CreativeCommons License, Non-commercial Share Alike
|
6
|
+
- LGPL, GNU Lesser General Public License
|
7
|
+
- MIT License
|
8
|
+
- Ruby License
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
11
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
12
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
= SixArm Ruby Gem: Generate secure random passwords.
|
3
|
+
|
4
|
+
Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
5
|
+
Copyright:: Copyright (c) 2006-2010 Joel Parker Henderson
|
6
|
+
License:: CreativeCommons License, Non-commercial Share Alike
|
7
|
+
License:: LGPL, GNU Lesser General Public License
|
8
|
+
|
9
|
+
Generates strong yet user-friendly passwords using Ruby's secure random cryptographic functions.
|
10
|
+
|
11
|
+
You can change how passwords are created using the optional parameters and the return value is a string, so you can do string methods on it.
|
12
|
+
|
13
|
+
The default length is 12 characters, which is sufficiently strong for most web applications. You can make this stronger as needed.
|
14
|
+
|
15
|
+
The default character array is optimized for usability and accessibility, to help mobile phone users and people with disabilities: all letters are lowercase and letters that look like numbers (specifically, "i", "l", "o") are not used.
|
16
|
+
|
17
|
+
== Method
|
18
|
+
* new: optional, named parameters are length (integer) and alternate character set (array of characters, which forces the password to contain only characters from the passed array)
|
19
|
+
|
20
|
+
== Examples
|
21
|
+
pt = PasswordText.new => "avzwbnxremcd"
|
22
|
+
pt4 = PasswordText.new(:length => 4) => "avzw"
|
23
|
+
pt4a = PasswordText.new(:length => 4, :chars => ['x','y','z']) => "yzyx"
|
24
|
+
|
25
|
+
== SecureRandom
|
26
|
+
|
27
|
+
Ruby 1.8.6 and older does not include a secure random number method so this gem checks to see if the SecureRandom class is defined and, if not, requires the sixarm_ruby_secure_random gem (http://github.com/sixarm/sixarm_ruby_secure_random).
|
28
|
+
|
@@ -0,0 +1,110 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
|
3
|
+
= SixArm Ruby Gem: PasswordText class to generate good secure random passwords.
|
4
|
+
|
5
|
+
Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
6
|
+
Copyright:: Copyright (c) 2006-2010 Joel Parker Henderson
|
7
|
+
License:: CreativeCommons License, Non-commercial Share Alike
|
8
|
+
License:: LGPL, GNU Lesser General Public License
|
9
|
+
|
10
|
+
Generates strong yet user-friendly passwords using Ruby's secure random cryptographic functions.
|
11
|
+
|
12
|
+
You can change how passwords are created using the optional parameters and the return value is a string, so you can do string methods on it.
|
13
|
+
|
14
|
+
The default length is 12 characters, which is sufficiently strong for most web applications. You can make this stronger as needed.
|
15
|
+
|
16
|
+
The default character array is optimized for usability and accessibility, to help mobile phone users and people with disabilities: all letters are lowercase and letters that look like numbers (specifically, "i", "l", "o") are not used.
|
17
|
+
|
18
|
+
== Method
|
19
|
+
|
20
|
+
* new: optional, named parameters are length (integer) and alternate character set (array of characters, which forces the password to contain only characters from the passed array)
|
21
|
+
|
22
|
+
== Examples
|
23
|
+
password = PasswordText.new => "avzwbnxremcd"
|
24
|
+
password = PasswordText.new(:length => 4) => "avzw"
|
25
|
+
password = PasswordText.new(:length => 4, :chars => ['x','y','z']) => "yzyx"
|
26
|
+
|
27
|
+
== SecureRandom
|
28
|
+
|
29
|
+
Ruby 1.8.6 and older does not include a secure random number method so this gem checks to see if the SecureRandom class is defined and, if not, requires the sixarm_ruby_secure_random gem (http://github.com/sixarm/sixarm_ruby_secure_random).
|
30
|
+
|
31
|
+
=end
|
32
|
+
|
33
|
+
|
34
|
+
if !defined?(SecureRandom) then require 'sixarm_ruby_secure_random' end
|
35
|
+
|
36
|
+
|
37
|
+
class PasswordText < String
|
38
|
+
|
39
|
+
|
40
|
+
# Default characters
|
41
|
+
@@chars=['a','b','c','d','e','f','g','h','j','k','m','n','p','q','r','s','t','u','v','w','x','y','z']
|
42
|
+
|
43
|
+
# Default length
|
44
|
+
@@length=12
|
45
|
+
|
46
|
+
|
47
|
+
# Return a new secure random password.
|
48
|
+
#
|
49
|
+
# The password has a given length (or the default)
|
50
|
+
# and is picked from a given character array (or the default).
|
51
|
+
#
|
52
|
+
# To set the default length, see #length.
|
53
|
+
#
|
54
|
+
# To set the default character array, see #chars
|
55
|
+
#
|
56
|
+
# ==Examples
|
57
|
+
# password = PasswordText.new => "avzwbnxremcd"
|
58
|
+
# password = PasswordText.new(4) => "avzw"
|
59
|
+
# password = PasswordText.new(4,['x','y','z']) => "yzyx"
|
60
|
+
#
|
61
|
+
# DEPRECATED, BREAKS CURRENT IMPLEMENTATION
|
62
|
+
# def initialize(length=@@length,chars=@@chars)
|
63
|
+
# super(Array.new(length){chars[SecureRandom.random_number(chars.size)]}.join)
|
64
|
+
# end
|
65
|
+
def initialize(opts={})
|
66
|
+
@@length ||= opts[:length],
|
67
|
+
@@chars ||= opts[:chars]
|
68
|
+
super(Array.new(length){chars[SecureRandom.random_number(chars.size)]}.join)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Get the default character array.
|
72
|
+
#
|
73
|
+
# To improve usability, the passwords only use lowercase letters.
|
74
|
+
# This helps people who use mobile phones and also helps people
|
75
|
+
# who have some kinds disabilities related to manual dexterity.
|
76
|
+
# We also omit letters that may be confused with numbers: "i", "l", "o".
|
77
|
+
#
|
78
|
+
# We choose this as a valuable tradeoff between usability and complexity.
|
79
|
+
|
80
|
+
def self.chars
|
81
|
+
@@chars
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
# Set the default character array
|
86
|
+
|
87
|
+
def self.chars=(chars)
|
88
|
+
@@chars=chars
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
# Get the default length
|
93
|
+
#
|
94
|
+
# We choose 12 characters to make a sufficiently strong password.
|
95
|
+
# for usual web applications. You can make this stronger as needed.
|
96
|
+
|
97
|
+
def self.length
|
98
|
+
@@length||=12
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
# Set the default length
|
103
|
+
|
104
|
+
def self.length=(length)
|
105
|
+
@@length=length
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'sixarm_ruby_password_text'
|
3
|
+
|
4
|
+
class PasswordTextTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_default
|
7
|
+
s = PasswordText.new
|
8
|
+
assert_equal(12,s.length)
|
9
|
+
assert_equal(0,s=~/^[abcdefghjkmnpqrstuvwxyz]{12}$/)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_with_length
|
13
|
+
s = PasswordText.new(20)
|
14
|
+
assert_equal(20,s.length)
|
15
|
+
assert_equal(0,s=~/^[abcdefghjkmnpqrstuvwxyz]{20}$/)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_with_length_and_characters
|
19
|
+
s = PasswordText.new(20,['a','b','c'])
|
20
|
+
assert_equal(20,s.length)
|
21
|
+
assert_equal(0,s=~/^[abc]{20}$/)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_chars
|
25
|
+
chars=['a','b','c']
|
26
|
+
PasswordText.chars=(chars)
|
27
|
+
assert_equal(chars,PasswordText.chars)
|
28
|
+
s=PasswordText.new
|
29
|
+
assert_equal(0,s=~/^[abc]+$/)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_length
|
33
|
+
length=99
|
34
|
+
PasswordText.length=(length)
|
35
|
+
assert_equal(length,PasswordText.length)
|
36
|
+
s=PasswordText.new
|
37
|
+
assert_equal(length,s.length)
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sixarm_ruby_password_text
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 2
|
8
|
+
- 1
|
9
|
+
version: 1.2.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- SixArm
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain:
|
16
|
+
- |
|
17
|
+
-----BEGIN CERTIFICATE-----
|
18
|
+
MIIDBDCCAm2gAwIBAgIJAKPwEETU5bHoMA0GCSqGSIb3DQEBBQUAMGAxCzAJBgNV
|
19
|
+
BAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1TYW4gRnJhbmNp
|
20
|
+
c2NvMQ8wDQYDVQQKEwZTaXhBcm0xEzARBgNVBAMTCnNpeGFybS5jb20wHhcNMTAx
|
21
|
+
MjEzMjMyNzEzWhcNMTMwOTA4MjMyNzEzWjBgMQswCQYDVQQGEwJVUzETMBEGA1UE
|
22
|
+
CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEPMA0GA1UEChMG
|
23
|
+
U2l4QXJtMRMwEQYDVQQDEwpzaXhhcm0uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GN
|
24
|
+
ADCBiQKBgQC94mD9JDwBsunsOI0VR3CXXbOWg9cWaWciwFyJNFiM7A9I8KPLfXUw
|
25
|
+
QC4czUe5ZuG4WHvinrWhkrCK+1dWBqoEClxdF/FoKO5a+tonGCjjmfy81JmFjjyx
|
26
|
+
eTsjsHyvw+Qik9kpf9aj6+pnkNrVswgNHVea2o9yabbEiS6VSeJWoQIDAQABo4HF
|
27
|
+
MIHCMB0GA1UdDgQWBBQzPJtqmSgc53eDN7aSzDQwr9TALDCBkgYDVR0jBIGKMIGH
|
28
|
+
gBQzPJtqmSgc53eDN7aSzDQwr9TALKFkpGIwYDELMAkGA1UEBhMCVVMxEzARBgNV
|
29
|
+
BAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xDzANBgNVBAoT
|
30
|
+
BlNpeEFybTETMBEGA1UEAxMKc2l4YXJtLmNvbYIJAKPwEETU5bHoMAwGA1UdEwQF
|
31
|
+
MAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAooEexP/oPam1TP71SyuhxMb+uTrZbSQe
|
32
|
+
jVB+ExRwWadGwaNPUA56d39qwavwP+iu+3JpeonNMVvbWXF5naCX/dNFIeREHzER
|
33
|
+
ZDRQYMqru9TEMna6HD9zpcstF7vwThGovlOQ+3Y6plQ4nMzipXcZ9THqs65PIL0q
|
34
|
+
eabwpCbAopo=
|
35
|
+
-----END CERTIFICATE-----
|
36
|
+
|
37
|
+
date: 2010-12-13 00:00:00 -08:00
|
38
|
+
default_executable:
|
39
|
+
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: bcrypt-ruby
|
42
|
+
prerelease: false
|
43
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
segments:
|
49
|
+
- 2
|
50
|
+
- 0
|
51
|
+
- 5
|
52
|
+
version: 2.0.5
|
53
|
+
type: :runtime
|
54
|
+
version_requirements: *id001
|
55
|
+
description:
|
56
|
+
email: sixarm@sixarm.com
|
57
|
+
executables: []
|
58
|
+
|
59
|
+
extensions: []
|
60
|
+
|
61
|
+
extra_rdoc_files: []
|
62
|
+
|
63
|
+
files:
|
64
|
+
- README.rdoc
|
65
|
+
- LICENSE.txt
|
66
|
+
- lib/sixarm_ruby_password_text.rb
|
67
|
+
- test/sixarm_ruby_password_text_test.rb
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://sixarm.com/
|
70
|
+
licenses: []
|
71
|
+
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
requirements: []
|
94
|
+
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 1.3.7
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: "SixArm Ruby Gem: Password text generator for strong web-savvy passwords"
|
100
|
+
test_files:
|
101
|
+
- test/sixarm_ruby_password_text_test.rb
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
e�϶��q��D�0��K�[G]i�`�t�p~醐�t�8�o�]�{4���fu�͠k�c�1��WŁ3l/*u�u�4�ڀՑm�ՖF�Wq��[I���2�&�������i���$�B
|