senha 0.0.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/LICENSE +25 -0
- data/NEWS.markdown +5 -0
- data/README.markdown +31 -0
- data/Rakefile +15 -0
- data/bin/senha +10 -0
- data/lib/senha.rb +8 -0
- data/lib/senha/base.rb +7 -0
- data/lib/senha/base/generator.rb +61 -0
- data/lib/senha/cli.rb +8 -0
- data/lib/senha/cli/application.rb +111 -0
- data/senha.gemspec +34 -0
- metadata +100 -0
data/LICENSE
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
Copyright (c) 2010-2011 Jacob Hammack, Hammackj LLC
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright
|
10
|
+
notice, this list of conditions and the following disclaimer in the
|
11
|
+
documentation and/or other materials provided with the distribution.
|
12
|
+
* Neither the name of the Jacob Hammack or Hammackj LLC nor the
|
13
|
+
names of its contributors may be used to endorse or promote products
|
14
|
+
derived from this software without specific prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
17
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
19
|
+
DISCLAIMED. IN NO EVENT SHALL JACOB HAMMACK or HAMMACKJ LLC BE LIABLE FOR ANY
|
20
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
21
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
22
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
23
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
24
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/NEWS.markdown
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# senha
|
2
|
+
|
3
|
+
Senha is a password generation tool for making random passwords based on a input requirement.
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
Using senha is relativley simple. Some example usage would be:
|
8
|
+
|
9
|
+
% senha -l
|
10
|
+
kpsyzatdpu
|
11
|
+
% senha -n
|
12
|
+
3993355865
|
13
|
+
% senha -a --length 20
|
14
|
+
M;w%Bwh8z-1NwYiS,#8h
|
15
|
+
% senha -a --length 20 --count 10
|
16
|
+
:QGZz:FqV88B4CQoPgiG
|
17
|
+
@m,obU-50uyI!#7-7l8A
|
18
|
+
i8u7R4mwcYI%.QBsEVtW
|
19
|
+
.LFchb;ni%#MC6#grF:,
|
20
|
+
NoarJHX3$Nz!hcu3AIjQ
|
21
|
+
cfrZGeG90ahfqSqPpq42
|
22
|
+
5;1WU@%:C9ZJMktx$sUa
|
23
|
+
$e5,6jdOSQ&zAV:H&6LS
|
24
|
+
4&yqxcF2Rj,qiMQMlTt,
|
25
|
+
#TyFKmzVTVer,;E-0^ro
|
26
|
+
|
27
|
+
# Issues
|
28
|
+
If you have any problems, bugs or feature requests please use the [github issue tracker](http://github.com/hammackj/senha/issues).
|
29
|
+
|
30
|
+
# Contact
|
31
|
+
You can reach me at jacob[dot]hammack[at]hammackj[dot]com.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
require "senha"
|
4
|
+
|
5
|
+
task :build do
|
6
|
+
system "gem build senha.gemspec"
|
7
|
+
end
|
8
|
+
|
9
|
+
task :release => :build do
|
10
|
+
system "gem push senha-#{Senha::VERSION}.gem"
|
11
|
+
end
|
12
|
+
|
13
|
+
task :clean do
|
14
|
+
system "rm *.gem"
|
15
|
+
end
|
data/bin/senha
ADDED
data/lib/senha.rb
ADDED
data/lib/senha/base.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Senha::Base
|
4
|
+
|
5
|
+
# A class for handling the generation of a password based on options
|
6
|
+
#
|
7
|
+
# @author Jacob Hammack <jacob.hammack@hammackj.com>
|
8
|
+
class Generator
|
9
|
+
attr_accessor :available_chars
|
10
|
+
|
11
|
+
# Creates a new instance of the Generator class
|
12
|
+
#
|
13
|
+
# @return [Generator]
|
14
|
+
def initialize(options)
|
15
|
+
@available_chars = Array.new
|
16
|
+
|
17
|
+
@numbers = ('0'..'9').to_a
|
18
|
+
@lower_case = ('a'..'z').to_a
|
19
|
+
@upper_case = ('A'..'Z').to_a
|
20
|
+
@punctuation = %w(. , ! : ;).to_a
|
21
|
+
@symbols = %w(! @ # $ % ^ & * - =).to_a
|
22
|
+
|
23
|
+
if options[:all]
|
24
|
+
@available_chars.concat @numbers
|
25
|
+
@available_chars.concat @lower_case
|
26
|
+
@available_chars.concat @upper_case
|
27
|
+
@available_chars.concat @symbols
|
28
|
+
@available_chars.concat @punctuation
|
29
|
+
else
|
30
|
+
if options[:numbers]
|
31
|
+
@available_chars.concat @numbers
|
32
|
+
end
|
33
|
+
|
34
|
+
if options[:lowercase]
|
35
|
+
@available_chars.concat @lower_case
|
36
|
+
end
|
37
|
+
|
38
|
+
if options[:uppercase]
|
39
|
+
@available_chars.concat @upper_case
|
40
|
+
end
|
41
|
+
|
42
|
+
if options[:symbols]
|
43
|
+
@available_chars.concat @symbols
|
44
|
+
end
|
45
|
+
|
46
|
+
if options[:punct]
|
47
|
+
@available_chars.concat @punctuation
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Generates a password
|
53
|
+
#
|
54
|
+
# @return [String] of the randomly generated password
|
55
|
+
def password(length = 10)
|
56
|
+
1.upto(length).collect do |a|
|
57
|
+
@available_chars[rand(@available_chars.size)]
|
58
|
+
end.join
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/senha/cli.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
module Senha
|
6
|
+
module CLI
|
7
|
+
|
8
|
+
# The Application class is responsible for the
|
9
|
+
#
|
10
|
+
# @author Jacob Hammack <jacob.hammack@hammackj.com>
|
11
|
+
class Application
|
12
|
+
|
13
|
+
# Creates a new instance of the Application Class
|
14
|
+
#
|
15
|
+
# @return [Application] New instance
|
16
|
+
def initialize
|
17
|
+
end
|
18
|
+
|
19
|
+
# Parses the command line arguments
|
20
|
+
#
|
21
|
+
def parse_arguments
|
22
|
+
begin
|
23
|
+
options = {}
|
24
|
+
|
25
|
+
options[:length] = 10
|
26
|
+
options[:count] = 1
|
27
|
+
|
28
|
+
opts = OptionParser.new do |opt|
|
29
|
+
opt.banner = "#{APP_NAME} v#{VERSION}\nJacob Hammack\nhttp://www.hammackj.com\n\n"
|
30
|
+
opt.banner << "Usage: #{APP_NAME} <options>"
|
31
|
+
opt.separator('')
|
32
|
+
opt.separator("Password Options")
|
33
|
+
|
34
|
+
opt.on("-n", "--numbers", "Use digits [0-9] in the password generation") do |n|
|
35
|
+
options[:numbers] = n
|
36
|
+
end
|
37
|
+
|
38
|
+
opt.on("-p", "--punctuation", "Use punctuation in the password generation") do |p|
|
39
|
+
options[:punct] = p
|
40
|
+
end
|
41
|
+
|
42
|
+
opt.on("-s", "--symbols", "Use symbols in the password generation") do |s|
|
43
|
+
options[:symbols] = s
|
44
|
+
end
|
45
|
+
|
46
|
+
opt.on("-l", "--lowercase", "Use lowercase [a-z] in the password generation") do |l|
|
47
|
+
options[:lowercase] = l
|
48
|
+
end
|
49
|
+
|
50
|
+
opt.on("-u", "--uppercase", "Use uppercase [A-Z] in the password generation") do |u|
|
51
|
+
options[:uppercase] = u
|
52
|
+
end
|
53
|
+
|
54
|
+
opt.on("-a", "--all-characters", "Use all available character sets for password generationA") do |a|
|
55
|
+
options[:all] = a
|
56
|
+
end
|
57
|
+
|
58
|
+
opt.separator ''
|
59
|
+
opt.separator 'Other Options'
|
60
|
+
|
61
|
+
opt.on("--count COUNT", Integer, "Number of passwords to generate, default is 1") do |count|
|
62
|
+
options[:count] = count#.to_i
|
63
|
+
end
|
64
|
+
|
65
|
+
opt.on("--length LENGTH", Integer, "Use uppercase in the password generation, default is 10") do |length|
|
66
|
+
options[:length] = length#.to_i
|
67
|
+
end
|
68
|
+
|
69
|
+
opt.on('-v', '--version', "Shows application version information") do
|
70
|
+
puts "#{APP_NAME} - #{VERSION}"
|
71
|
+
exit
|
72
|
+
end
|
73
|
+
|
74
|
+
opt.on_tail("-?", "--help", "Show this message") { |help|
|
75
|
+
puts opt.to_s + "\n"
|
76
|
+
exit
|
77
|
+
}
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
if ARGV.length != 0
|
82
|
+
opts.parse!
|
83
|
+
else
|
84
|
+
puts opts.to_s + "\n"
|
85
|
+
exit
|
86
|
+
end
|
87
|
+
|
88
|
+
options
|
89
|
+
rescue OptionParser::MissingArgument => m
|
90
|
+
puts opts.to_s + "\n"
|
91
|
+
exit
|
92
|
+
rescue OptionParser::InvalidOption => i
|
93
|
+
puts opts.to_s + "\n"
|
94
|
+
exit
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Main body of the Application class
|
99
|
+
#
|
100
|
+
def run
|
101
|
+
options = parse_arguments
|
102
|
+
|
103
|
+
gen = Senha::Base::Generator.new(options)
|
104
|
+
|
105
|
+
options[:count].times do
|
106
|
+
puts gen.password(options[:length])
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/senha.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
base = __FILE__
|
4
|
+
$:.unshift(File.join(File.dirname(base), 'lib'))
|
5
|
+
|
6
|
+
require 'senha'
|
7
|
+
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = "#{Senha::APP_NAME}"
|
10
|
+
s.version = Senha::VERSION
|
11
|
+
s.homepage = "http://www.hammackj.com/"
|
12
|
+
s.summary = "#{Senha::APP_NAME}"
|
13
|
+
s.description = "#{Senha::APP_NAME} is a password generation tool"
|
14
|
+
s.license = "BSD"
|
15
|
+
|
16
|
+
s.author = "Jacob Hammack"
|
17
|
+
s.email = "jacob.hammack@hammackj.com"
|
18
|
+
|
19
|
+
s.files = Dir['[A-Z]*'] + Dir['lib/**/*'] + ['senha.gemspec']
|
20
|
+
s.default_executable = "#{Senha::APP_NAME}"
|
21
|
+
s.executables = ["#{Senha::APP_NAME}"]
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
|
24
|
+
s.has_rdoc = 'yard'
|
25
|
+
s.extra_rdoc_files = ["README.markdown", "LICENSE", "NEWS.markdown"]
|
26
|
+
|
27
|
+
s.required_rubygems_version = ">= 1.3.6"
|
28
|
+
s.rubyforge_project = "#{Senha::APP_NAME}"
|
29
|
+
|
30
|
+
s.add_development_dependency("rspec", ">= 2.4.0")
|
31
|
+
s.add_development_dependency("rcov", ">= 0.9.9")
|
32
|
+
s.add_development_dependency("yard", ">= 0.6.4")
|
33
|
+
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: senha
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jacob Hammack
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-02-17 00:00:00 -06:00
|
14
|
+
default_executable: senha
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 2.4.0
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rcov
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.9.9
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: yard
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.6.4
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
description: senha is a password generation tool
|
50
|
+
email: jacob.hammack@hammackj.com
|
51
|
+
executables:
|
52
|
+
- senha
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files:
|
56
|
+
- README.markdown
|
57
|
+
- LICENSE
|
58
|
+
- NEWS.markdown
|
59
|
+
files:
|
60
|
+
- LICENSE
|
61
|
+
- NEWS.markdown
|
62
|
+
- Rakefile
|
63
|
+
- README.markdown
|
64
|
+
- lib/senha/base/generator.rb
|
65
|
+
- lib/senha/base.rb
|
66
|
+
- lib/senha/cli/application.rb
|
67
|
+
- lib/senha/cli.rb
|
68
|
+
- lib/senha.rb
|
69
|
+
- senha.gemspec
|
70
|
+
- bin/senha
|
71
|
+
has_rdoc: yard
|
72
|
+
homepage: http://www.hammackj.com/
|
73
|
+
licenses:
|
74
|
+
- BSD
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: "0"
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.3.6
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project: senha
|
95
|
+
rubygems_version: 1.5.2
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: senha
|
99
|
+
test_files: []
|
100
|
+
|