webget-password_text 1.1.5
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/password_text.rb +38 -0
- data/test/unit/password_text_test.rb +19 -0
- metadata +61 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
# = PasswordText
|
2
|
+
#
|
3
|
+
# Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
4
|
+
# Copyright:: Copyright (c) 2006-2008 Joel Parker Henderson
|
5
|
+
# License:: CreativeCommons License, Non-commercial Share Alike
|
6
|
+
# License:: LGPL, GNU Lesser General Public License
|
7
|
+
#
|
8
|
+
# Password tool to create strong user-friendly passwords,
|
9
|
+
# using Ruby's secure random cryptographic functions.
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
# PasswordText.new => "avzwbnxrem"
|
13
|
+
#
|
14
|
+
# PasswordText is a string, so you can do any string methods on it.
|
15
|
+
# You can change how passwords are randomly created however you want.
|
16
|
+
#
|
17
|
+
# We choose 10 characters to make a sufficiently strong password.
|
18
|
+
# for usual web applications. You can make this stronger as needed.
|
19
|
+
#
|
20
|
+
# We know users are confused by upper/lower case so we use only lowercase,
|
21
|
+
# and by letters vs. numbers like "oh" and "zero" so we use only letters.
|
22
|
+
#
|
23
|
+
# We choose this as an acceptable tradeoff between usability and complexity.
|
24
|
+
# We also choose this because it is much better for users on smartphones.
|
25
|
+
##
|
26
|
+
|
27
|
+
require 'securerandom'
|
28
|
+
|
29
|
+
class PasswordText < String
|
30
|
+
|
31
|
+
COUNT = 10
|
32
|
+
CHARS = ['a','b','c','d','e','f','g','h','j','k','m','n','p','r','s','t','u','v','w','x','y','z']
|
33
|
+
|
34
|
+
def initialize
|
35
|
+
super(Array.new(COUNT){CHARS[SecureRandom.random_number(CHARS.size)]}.join)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'webget-password-text'
|
3
|
+
|
4
|
+
class PasswordTextTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_all
|
7
|
+
20.times{
|
8
|
+
x=PasswordText.new
|
9
|
+
assert(x.is_a?(String))
|
10
|
+
assert_equal(x.length,PasswordText::COUNT)
|
11
|
+
assert(x=~/^[a-z]+$/,"lowercase letters:#{x}")
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webget-password_text
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- WebGet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-05 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bcrypt-ruby
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.3
|
23
|
+
version:
|
24
|
+
description:
|
25
|
+
email: webget@webget.com
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- lib/password_text.rb
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: http://webget.com/
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "0"
|
46
|
+
version:
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
requirements: []
|
54
|
+
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.2.0
|
57
|
+
signing_key:
|
58
|
+
specification_version: 2
|
59
|
+
summary: Generate secure random password text strings
|
60
|
+
test_files:
|
61
|
+
- test/unit/password_text_test.rb
|