webget_ruby_password_text 1.2.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.tar.gz.sig ADDED
@@ -0,0 +1 @@
1
+ �~x9VǑC�E��� A���I����.s���a[�~iI��y�+�Kn�q�B_���9
@@ -0,0 +1,102 @@
1
+ =begin rdoc
2
+
3
+ = WebGet Ruby Gem: PasswordText class to generate 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
+ Password tool to create strong user-friendly passwords,
11
+ using Ruby's secure random cryptographic functions.
12
+
13
+ ==Examples
14
+ PasswordText.new => "avzwbnxremcd"
15
+ PasswordText.new(4) => "avzw"
16
+ PasswordText.new(4,['x','y','z']) => "yzyx"
17
+
18
+ PasswordText is a string, so you can do string methods on it.
19
+ You can change how passwords are randomly created however you want.
20
+
21
+ The default length is 12 to make a sufficiently strong password.
22
+ for usual web applications. You can make this stronger as needed.
23
+
24
+ The default character array is chosen for the best usability,
25
+ to help people who use mobile phones and who have disabilities:
26
+ all lowercase and omitting "i", "l", "o" which look like numbers.
27
+
28
+ If SecureRandom is not defined, e.g. if you are using Ruby 1.8.6,
29
+ then we require our webget_ruby_secure_random gem which provides it.
30
+
31
+ =end
32
+
33
+
34
+ class PasswordText < String
35
+
36
+ if !defined?(SecureRandom) then require 'webget_ruby_secure_random' end
37
+
38
+ # Default characters
39
+ @@chars=['a','b','c','d','e','f','g','h','j','k','m','n','p','q','r','s','t','u','v','w','x','y','z']
40
+
41
+ # Default length
42
+ @@length=12
43
+
44
+
45
+ # Return a new secure random password.
46
+ #
47
+ # The password has a given length (or the default)
48
+ # and is picked from a given character array (or the default).
49
+ #
50
+ # To set the default length, see #length.
51
+ #
52
+ # To set the default character array, see #chars
53
+ #
54
+ # ==Examples
55
+ # PasswordText.new => "avzwbnxremcd"
56
+ # PasswordText.new(4) => "avzw"
57
+ # PasswordText.new(4,['x','y','z']) => "yzyx"
58
+
59
+ def initialize(length=@@length,chars=@@chars)
60
+ super(Array.new(length){chars[SecureRandom.random_number(chars.size)]}.join)
61
+ end
62
+
63
+ # Get the default character array.
64
+ #
65
+ # To improve usability, the passwords only use lowercase letters.
66
+ # This helps people who use mobile phones and also helps people
67
+ # who have some kinds disabilities related to manual dexterity.
68
+ # We also omit letters that may be confused with numbers: "i", "l", "o".
69
+ #
70
+ # We choose this as a valuable tradeoff between usability and complexity.
71
+
72
+ def self.chars
73
+ @@chars
74
+ end
75
+
76
+
77
+ # Set the default character array
78
+
79
+ def self.chars=(chars)
80
+ @@chars=chars
81
+ end
82
+
83
+
84
+ # Get the default length
85
+ #
86
+ # We choose 12 characters to make a sufficiently strong password.
87
+ # for usual web applications. You can make this stronger as needed.
88
+
89
+ def self.length
90
+ @@length||=12
91
+ end
92
+
93
+
94
+ # Set the default length
95
+
96
+ def self.length=(length)
97
+ @@length=length
98
+ end
99
+
100
+ end
101
+
102
+
@@ -0,0 +1,44 @@
1
+ require 'test/unit'
2
+ require 'webget_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,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webget_ruby_password_text
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - WebGet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDvDCCAyWgAwIBAgIJAIlSqEkDQaZIMA0GCSqGSIb3DQEBBQUAMIGbMQswCQYD
14
+ VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5j
15
+ aXNjbzETMBEGA1UEChMKV2ViR2V0LmNvbTETMBEGA1UECxMKV2ViR2V0LmNvbTET
16
+ MBEGA1UEAxMKV2ViR2V0LmNvbTEgMB4GCSqGSIb3DQEJARYRd2ViZ2V0QHdlYmdl
17
+ dC5jb20wHhcNMDkwMjI2MTk0NDU4WhcNMTExMTIzMTk0NDU4WjCBmzELMAkGA1UE
18
+ BhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDVNhbiBGcmFuY2lz
19
+ Y28xEzARBgNVBAoTCldlYkdldC5jb20xEzARBgNVBAsTCldlYkdldC5jb20xEzAR
20
+ BgNVBAMTCldlYkdldC5jb20xIDAeBgkqhkiG9w0BCQEWEXdlYmdldEB3ZWJnZXQu
21
+ Y29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDXCFYfW6hCQl0ToNjaMIXG
22
+ ZfPF6OoR20BO/Tg6V37qPi7gDSZ6vIC6Mxcs8LtEcju85cD9lnKKl/lo4S5/w9Ha
23
+ hGD2ZFFfbF8420X5Za5G2KuriS3GzRz7F5dKCTjb1NH9TPlgOc71bcrDmCwwtFJl
24
+ T+tdfBju0YxLSBiMXf4y5QIDAQABo4IBBDCCAQAwHQYDVR0OBBYEFHB1kXO/Xd4g
25
+ G+AJ2/wwh6JOWXzNMIHQBgNVHSMEgcgwgcWAFHB1kXO/Xd4gG+AJ2/wwh6JOWXzN
26
+ oYGhpIGeMIGbMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQG
27
+ A1UEBxMNU2FuIEZyYW5jaXNjbzETMBEGA1UEChMKV2ViR2V0LmNvbTETMBEGA1UE
28
+ CxMKV2ViR2V0LmNvbTETMBEGA1UEAxMKV2ViR2V0LmNvbTEgMB4GCSqGSIb3DQEJ
29
+ ARYRd2ViZ2V0QHdlYmdldC5jb22CCQCJUqhJA0GmSDAMBgNVHRMEBTADAQH/MA0G
30
+ CSqGSIb3DQEBBQUAA4GBADzVXlwuff0/w3yK4LflGKKhtC3oChIrwmSyP6tk628N
31
+ BHokpc4Kz63xSXqzYTnBS7rFBwlYThtNalQeWmoUjGh3Z0ZR0JlhU0ln8899LuJ3
32
+ DXnLFY0cVuBnNDMOOFl8vk1qIcZjcTovhzgcixpG6Uk5qmUsKHRLQf4oQJx7TfLK
33
+ -----END CERTIFICATE-----
34
+
35
+ date: 2010-02-17 00:00:00 -08:00
36
+ default_executable:
37
+ dependencies:
38
+ - !ruby/object:Gem::Dependency
39
+ name: bcrypt-ruby
40
+ type: :runtime
41
+ version_requirement:
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.0.5
47
+ version:
48
+ - !ruby/object:Gem::Dependency
49
+ name: webget_ruby_secure_random
50
+ type: :runtime
51
+ version_requirement:
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.2.0
57
+ version:
58
+ description:
59
+ email: webget@webget.com
60
+ executables: []
61
+
62
+ extensions: []
63
+
64
+ extra_rdoc_files: []
65
+
66
+ files:
67
+ - lib/webget_ruby_password_text.rb
68
+ has_rdoc: true
69
+ homepage: http://webget.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
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ version:
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.3.5
93
+ signing_key:
94
+ specification_version: 3
95
+ summary: "WebGet Ruby Gem: Password text generator for strong web-savvy passwords"
96
+ test_files:
97
+ - test/webget_ruby_password_text_test.rb
metadata.gz.sig ADDED
Binary file