password_characters 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +76 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/password_characters +29 -0
- data/bin/setup +8 -0
- data/lib/password_and_ordinals.rb +47 -0
- data/lib/password_characters/version.rb +3 -0
- data/lib/password_characters.rb +5 -0
- data/password_characters.gemspec +27 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d634910661c0279fc63dafb14a8d1f9f130d1f47
|
4
|
+
data.tar.gz: 6eead34f52538c8bd68de5e550502e7f66a6b789
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 303450bc636953c811b9f9ba00beb88975002e1d69f1bf76b8a5e0f47f1223e111a2146b2ce67428ec8143bcc050a18242d3098ee39d7ec1b5f2b91a53e4243b
|
7
|
+
data.tar.gz: 412922b4001d434972d2595966de65832644954c1506fba5867be0515ed47743c9447069efe03b8d7aff663dbcdc8ccab7feadd956ad45096561a3f0c7e4907a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
password_characters
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.3.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
password_characters (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (4.2.6)
|
10
|
+
i18n (~> 0.7)
|
11
|
+
json (~> 1.7, >= 1.7.7)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
aruba (0.14.1)
|
16
|
+
childprocess (~> 0.5.6)
|
17
|
+
contracts (~> 0.9)
|
18
|
+
cucumber (>= 1.3.19)
|
19
|
+
ffi (~> 1.9.10)
|
20
|
+
rspec-expectations (>= 2.99)
|
21
|
+
thor (~> 0.19)
|
22
|
+
builder (3.2.2)
|
23
|
+
childprocess (0.5.9)
|
24
|
+
ffi (~> 1.0, >= 1.0.11)
|
25
|
+
contracts (0.14.0)
|
26
|
+
cucumber (2.3.3)
|
27
|
+
builder (>= 2.1.2)
|
28
|
+
cucumber-core (~> 1.4.0)
|
29
|
+
cucumber-wire (~> 0.0.1)
|
30
|
+
diff-lcs (>= 1.1.3)
|
31
|
+
gherkin (~> 3.2.0)
|
32
|
+
multi_json (>= 1.7.5, < 2.0)
|
33
|
+
multi_test (>= 0.1.2)
|
34
|
+
cucumber-core (1.4.0)
|
35
|
+
gherkin (~> 3.2.0)
|
36
|
+
cucumber-wire (0.0.1)
|
37
|
+
diff-lcs (1.2.5)
|
38
|
+
ffi (1.9.10)
|
39
|
+
gherkin (3.2.0)
|
40
|
+
i18n (0.7.0)
|
41
|
+
json (1.8.3)
|
42
|
+
minitest (5.9.0)
|
43
|
+
multi_json (1.12.0)
|
44
|
+
multi_test (0.1.2)
|
45
|
+
rake (10.4.2)
|
46
|
+
rspec (3.4.0)
|
47
|
+
rspec-core (~> 3.4.0)
|
48
|
+
rspec-expectations (~> 3.4.0)
|
49
|
+
rspec-mocks (~> 3.4.0)
|
50
|
+
rspec-core (3.4.4)
|
51
|
+
rspec-support (~> 3.4.0)
|
52
|
+
rspec-expectations (3.4.0)
|
53
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
+
rspec-support (~> 3.4.0)
|
55
|
+
rspec-mocks (3.4.1)
|
56
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
57
|
+
rspec-support (~> 3.4.0)
|
58
|
+
rspec-support (3.4.1)
|
59
|
+
thor (0.19.1)
|
60
|
+
thread_safe (0.3.5)
|
61
|
+
tzinfo (1.2.2)
|
62
|
+
thread_safe (~> 0.1)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
ruby
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
activesupport (= 4.2.6)
|
69
|
+
aruba (= 0.14.1)
|
70
|
+
bundler (~> 1.12)
|
71
|
+
password_characters!
|
72
|
+
rake (~> 10.0)
|
73
|
+
rspec (= 3.4.0)
|
74
|
+
|
75
|
+
BUNDLED WITH
|
76
|
+
1.12.5
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Nigel Lowry
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# password_characters
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/password_characters`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'password_characters'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install password_characters
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/password_characters.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "password_characters"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative '../lib/password_and_ordinals'
|
3
|
+
|
4
|
+
require 'active_support'
|
5
|
+
require 'active_support/core_ext/string'
|
6
|
+
|
7
|
+
password = if ARGV.any?
|
8
|
+
ARGV[0]
|
9
|
+
else
|
10
|
+
puts 'Enter password:'
|
11
|
+
gets
|
12
|
+
end
|
13
|
+
|
14
|
+
character_ordinals = if ARGV.any?
|
15
|
+
ARGV[1]
|
16
|
+
else
|
17
|
+
puts 'Enter indices:'
|
18
|
+
gets
|
19
|
+
end
|
20
|
+
|
21
|
+
def character_ordinals_to_integer_array(character_ordinals)
|
22
|
+
character_ordinals.split(',').map(&:to_i)
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
puts PasswordAndOrdinals.new(password.squish, character_ordinals_to_integer_array(character_ordinals.squish)).characters.join ' '
|
27
|
+
rescue Exception => e
|
28
|
+
abort e.message
|
29
|
+
end
|
data/bin/setup
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/core_ext/object'
|
5
|
+
|
6
|
+
class PasswordAndOrdinals
|
7
|
+
def initialize(password, ordinals)
|
8
|
+
raise(ArgumentError, "#{ordinals} does not ask for any characters") if ordinals.empty?
|
9
|
+
raise(ArgumentError, "#{ordinals} only asks for one character") if ordinals.one?
|
10
|
+
|
11
|
+
raise(ArgumentError, "#{ordinals} is not in ascending order") unless sorted?(ordinals)
|
12
|
+
|
13
|
+
raise(ArgumentError, "#{ordinals.uniq.to_sentence} duplicated in #{ordinals}") unless uniq?(ordinals)
|
14
|
+
raise(ArgumentError, "#{ordinals} would reveal entire password") unless ordinals.size < password.size # needs to come after checking duplicates
|
15
|
+
|
16
|
+
raise(ArgumentError, "#{ordinals_out_of_bounds(password, ordinals).to_sentence} out of bounds") unless ordinals.all? { |i| i.in? ordinal_range(password) }
|
17
|
+
|
18
|
+
@password_array = password.chars
|
19
|
+
@indices = indices ordinals
|
20
|
+
end
|
21
|
+
|
22
|
+
def characters
|
23
|
+
@indices.map { |i| @password_array.at i }
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def sorted?(a)
|
29
|
+
a.sort == a
|
30
|
+
end
|
31
|
+
|
32
|
+
def uniq?(a)
|
33
|
+
a.uniq == a
|
34
|
+
end
|
35
|
+
|
36
|
+
def ordinals_out_of_bounds(password, ordinals)
|
37
|
+
ordinals.reject { |i| i.in? ordinal_range(password) }
|
38
|
+
end
|
39
|
+
|
40
|
+
def ordinal_range(password)
|
41
|
+
1..password.length
|
42
|
+
end
|
43
|
+
|
44
|
+
def indices(ordinals)
|
45
|
+
ordinals.map { |n| n - 1 }
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'password_characters/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "password_characters"
|
8
|
+
spec.version = PasswordCharacters::VERSION
|
9
|
+
spec.authors = ["Nigel Lowry"]
|
10
|
+
spec.email = ["nigel-lowry@ultra.eclipse.co.uk"]
|
11
|
+
|
12
|
+
spec.summary = %q{Allows you to get characters from a password}
|
13
|
+
spec.description = %q{Can be used to log in to Web sites which ask for specific characters from your password}
|
14
|
+
spec.homepage = "https://github.com/nigel-lowry/password_characters"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency 'activesupport', '4.2.6'
|
25
|
+
spec.add_development_dependency 'aruba', '0.14.1'
|
26
|
+
spec.add_development_dependency 'rspec', '3.4.0'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: password_characters
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nigel Lowry
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 4.2.6
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 4.2.6
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: aruba
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.14.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.4.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.4.0
|
83
|
+
description: Can be used to log in to Web sites which ask for specific characters
|
84
|
+
from your password
|
85
|
+
email:
|
86
|
+
- nigel-lowry@ultra.eclipse.co.uk
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".ruby-gemset"
|
94
|
+
- ".ruby-version"
|
95
|
+
- ".travis.yml"
|
96
|
+
- Gemfile
|
97
|
+
- Gemfile.lock
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/console
|
102
|
+
- bin/password_characters
|
103
|
+
- bin/setup
|
104
|
+
- lib/password_and_ordinals.rb
|
105
|
+
- lib/password_characters.rb
|
106
|
+
- lib/password_characters/version.rb
|
107
|
+
- password_characters.gemspec
|
108
|
+
homepage: https://github.com/nigel-lowry/password_characters
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.5.1
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Allows you to get characters from a password
|
132
|
+
test_files: []
|