to_pass 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/to_pass +1 -38
- data/lib/to_pass/algorithm_reader.rb +3 -0
- data/lib/to_pass/base.rb +3 -0
- data/lib/to_pass/cli.rb +65 -0
- data/lib/to_pass/converter.rb +3 -0
- data/lib/to_pass/integration.rb +3 -0
- data/lib/to_pass/string_conversions.rb +3 -0
- data/lib/to_pass.rb +7 -3
- data/test/helper.rb +3 -0
- data/test/test_algorithm_reader.rb +3 -0
- data/test/test_base.rb +3 -0
- data/test/test_cli.rb +41 -0
- data/test/test_converter.rb +3 -0
- data/test/test_integration.rb +3 -25
- data/test/test_string_conversions.rb +3 -0
- metadata +7 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/bin/to_pass
CHANGED
@@ -5,43 +5,6 @@
|
|
5
5
|
base_path = ( File.expand_path(File.dirname(__FILE__)+'/..') )
|
6
6
|
$LOAD_PATH << base_path unless $LOAD_PATH.include?(base_path)
|
7
7
|
|
8
|
-
require 'optparse'
|
9
8
|
require 'lib/to_pass'
|
10
9
|
|
11
|
-
|
12
|
-
options = {
|
13
|
-
:pipe_usage => ARGV[0].nil?,
|
14
|
-
:algorithm => 'basic_de'
|
15
|
-
}
|
16
|
-
|
17
|
-
OptionParser.new do |opts|
|
18
|
-
opts.banner = "Usage: #{__FILE__} [options] passphrase"
|
19
|
-
opts.separator ""
|
20
|
-
|
21
|
-
opts.on('-a', '--algorithm ALGORITM', "use specified algorithm for transformation") do |value|
|
22
|
-
options[:algorithm] = value
|
23
|
-
end
|
24
|
-
|
25
|
-
opts.separator ""
|
26
|
-
|
27
|
-
opts.on_tail("-h", "--help", "Show this message") do
|
28
|
-
puts opts
|
29
|
-
exit
|
30
|
-
end
|
31
|
-
end.parse!
|
32
|
-
|
33
|
-
# get input string
|
34
|
-
string= unless options[:pipe_usage]
|
35
|
-
ARGV[0]
|
36
|
-
else
|
37
|
-
$stdin.read.chomp
|
38
|
-
end
|
39
|
-
|
40
|
-
# perform "heavy" work
|
41
|
-
password = ToPass::Base.new( string, options[:algorithm] ).to_s
|
42
|
-
|
43
|
-
if options[:pipe_usage]
|
44
|
-
$stdout << password
|
45
|
-
else
|
46
|
-
puts password
|
47
|
-
end
|
10
|
+
ToPass::Cli.new.output
|
data/lib/to_pass/base.rb
CHANGED
data/lib/to_pass/cli.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# vim:ft=ruby:enc=utf-8
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
module ToPass
|
7
|
+
class Cli
|
8
|
+
def initialize
|
9
|
+
@options = parse_options
|
10
|
+
@string = get_input_string
|
11
|
+
@password = transform
|
12
|
+
end
|
13
|
+
|
14
|
+
def output
|
15
|
+
if @options[:pipe_usage]
|
16
|
+
$stdout << @password
|
17
|
+
else
|
18
|
+
puts @password
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
# parse the options
|
25
|
+
def parse_options
|
26
|
+
options = {
|
27
|
+
:algorithm => 'basic_de'
|
28
|
+
}
|
29
|
+
|
30
|
+
OptionParser.new do |opts|
|
31
|
+
opts.banner = "Usage: #{__FILE__} [options] passphrase"
|
32
|
+
opts.separator ""
|
33
|
+
|
34
|
+
opts.on('-a', '--algorithm ALGORITM', "use specified algorithm for transformation") do |value|
|
35
|
+
options[:algorithm] = value
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.separator ""
|
39
|
+
|
40
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
41
|
+
puts opts
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
end.parse!
|
45
|
+
|
46
|
+
options[:pipe_usage] = ARGV[0].nil?
|
47
|
+
|
48
|
+
options
|
49
|
+
end
|
50
|
+
|
51
|
+
# get the input string
|
52
|
+
def get_input_string
|
53
|
+
unless @options[:pipe_usage]
|
54
|
+
ARGV[0]
|
55
|
+
else
|
56
|
+
$stdin.read.chomp
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# perform "heavy" work
|
61
|
+
def transform
|
62
|
+
Base.new( @string, @options[:algorithm] ).to_s
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/to_pass/converter.rb
CHANGED
data/lib/to_pass/integration.rb
CHANGED
data/lib/to_pass.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# vim:ft=ruby:enc=utf-8
|
3
|
+
|
1
4
|
# Library to convert a String into a Password
|
2
5
|
module ToPass
|
3
6
|
# version of gem, read directly from the VERSION-File
|
@@ -6,9 +9,10 @@ module ToPass
|
|
6
9
|
# name of gem
|
7
10
|
APP_NAME = 'to_pass'
|
8
11
|
|
9
|
-
autoload :
|
10
|
-
autoload :StringConversions, 'lib/to_pass/string_conversions'
|
12
|
+
autoload :AlgorithmReader, 'lib/to_pass/algorithm_reader'
|
11
13
|
autoload :Base, 'lib/to_pass/base'
|
14
|
+
autoload :Cli, 'lib/to_pass/cli.rb'
|
15
|
+
autoload :Converter, 'lib/to_pass/converter'
|
12
16
|
autoload :Integration, 'lib/to_pass/integration'
|
13
|
-
autoload :
|
17
|
+
autoload :StringConversions, 'lib/to_pass/string_conversions'
|
14
18
|
end
|
data/test/helper.rb
CHANGED
data/test/test_base.rb
CHANGED
data/test/test_cli.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# vim:ft=ruby:enc=utf-8
|
3
|
+
|
4
|
+
require File.dirname(__FILE__)+'/helper'
|
5
|
+
|
6
|
+
class TestCli < Test::Unit::TestCase
|
7
|
+
test_presence ToPass::Cli
|
8
|
+
|
9
|
+
def test_cli_usage_without_algorithm
|
10
|
+
assert_nothing_raised do
|
11
|
+
assert_equal "t35t", `bin/to_pass test`.chomp
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_cli_usage_with_algorithm
|
16
|
+
assert_nothing_raised do
|
17
|
+
assert_equal "ti1p4u2", `bin/to_pass 'there is one problem for us, too' -a basic_en`.chomp
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_cli_usage_with_pipes
|
22
|
+
assert_nothing_raised do
|
23
|
+
assert_equal 't35t', `echo "test" | bin/to_pass`
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def test_cli_usage_with_user_algorithm
|
29
|
+
with_algorithm_in_user_dir do
|
30
|
+
assert_equal "le1/2%z", `bin/to_pass 'leasbpc' -a user_alg`.chomp
|
31
|
+
assert_equal "le1/2%z", `bin/to_pass 'luke eats all sausagages because peter cries' -a user_alg`.chomp
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_cli_usage_with_pipes_and_user_algorithm
|
36
|
+
with_algorithm_in_user_dir do
|
37
|
+
assert_equal "le1/2%z", `echo 'leasbpc' | bin/to_pass -a user_alg`.chomp
|
38
|
+
assert_equal "le1/2%z", `echo 'luke eats all sausagages because peter cries' | bin/to_pass -a user_alg`.chomp
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/test/test_converter.rb
CHANGED
data/test/test_integration.rb
CHANGED
@@ -1,24 +1,9 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# vim:ft=ruby:enc=utf-8
|
3
|
+
|
1
4
|
require File.dirname(__FILE__)+'/helper'
|
2
5
|
|
3
6
|
class TestIntegration < Test::Unit::TestCase
|
4
|
-
def test_cli_usage_without_algorithm
|
5
|
-
assert_nothing_raised do
|
6
|
-
assert_equal "t35t", `bin/to_pass test`.chomp
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_cli_usage_with_algorithm
|
11
|
-
assert_nothing_raised do
|
12
|
-
assert_equal "ti1p4u2", `bin/to_pass 'there is one problem for us, too' -a basic_en`.chomp
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_cli_usage_with_pipes
|
17
|
-
assert_nothing_raised do
|
18
|
-
assert_equal 't35t', `echo "test" | bin/to_pass`
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
7
|
def test_module_integration
|
23
8
|
assert_nothing_raised do
|
24
9
|
str = "test"
|
@@ -27,11 +12,4 @@ class TestIntegration < Test::Unit::TestCase
|
|
27
12
|
assert_equal 't35t', str.to_pass
|
28
13
|
end
|
29
14
|
end
|
30
|
-
|
31
|
-
def test_cli_usage_with_user_algorithm
|
32
|
-
with_algorithm_in_user_dir do
|
33
|
-
assert_equal "le1/2%z", `bin/to_pass 'leasbpc' -a user_alg`.chomp
|
34
|
-
assert_equal "le1/2%z", `bin/to_pass 'luke eats all sausagages because peter cries' -a user_alg`.chomp
|
35
|
-
end
|
36
|
-
end
|
37
15
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_pass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthias Viehweger
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-24 00:00:00 +02:00
|
19
19
|
default_executable: to_pass
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/to_pass.rb
|
72
72
|
- lib/to_pass/algorithm_reader.rb
|
73
73
|
- lib/to_pass/base.rb
|
74
|
+
- lib/to_pass/cli.rb
|
74
75
|
- lib/to_pass/converter.rb
|
75
76
|
- lib/to_pass/integration.rb
|
76
77
|
- lib/to_pass/string_conversions.rb
|
@@ -78,6 +79,7 @@ files:
|
|
78
79
|
- test/helper.rb
|
79
80
|
- test/test_algorithm_reader.rb
|
80
81
|
- test/test_base.rb
|
82
|
+
- test/test_cli.rb
|
81
83
|
- test/test_converter.rb
|
82
84
|
- test/test_integration.rb
|
83
85
|
- test/test_string_conversions.rb
|
@@ -119,6 +121,7 @@ test_files:
|
|
119
121
|
- test/helper.rb
|
120
122
|
- test/test_algorithm_reader.rb
|
121
123
|
- test/test_base.rb
|
124
|
+
- test/test_cli.rb
|
122
125
|
- test/test_converter.rb
|
123
126
|
- test/test_integration.rb
|
124
127
|
- test/test_string_conversions.rb
|