oplop 0.0.8 → 2.0.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.
- checksums.yaml +5 -5
- data/.ruby-version +1 -0
- data/README.md +30 -4
- data/bin/loplop +68 -0
- data/bin/oplop +1 -1
- data/lib/oplop.rb +28 -25
- data/lib/oplop/cli.rb +23 -9
- data/lib/oplop/version.rb +2 -2
- data/shippable.yml +16 -0
- data/spec/oplop_spec.rb +4 -13
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fe387253f3e7471b962a13a3f4f9f6adf74779a51967b267cebb1cdb2262345c
|
4
|
+
data.tar.gz: 04ebb187af0d95379363d07af159e85b5a6cbbbca711ee2f131e8193e3805ba1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82b7ec63eaabe9d9b3aee0b00631a4d7f8fb74d8a2273418c76e84f39995cd7dd68f4e67b0660d5221767df7faa27aea5476d76f583f0609cf7c9bf0f6ee39bb
|
7
|
+
data.tar.gz: f31f3e781ae750b59f91e46577c2631c755ddde0f3831adf16988985cca245070cae97dfae53427cd3dedf94a7b771ead7f5bd008f27a3100fce415a2a3d246d
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.0
|
data/README.md
CHANGED
@@ -1,22 +1,48 @@
|
|
1
1
|
Oplop
|
2
2
|
=====
|
3
3
|
|
4
|
-
This is a ruby implementation of Oplop http://code.google.com/p/oplop/
|
4
|
+
This is a ruby implementation of Oplop http://code.google.com/p/oplop/, supporting the long oplop variation (see: https://github.com/thedod/loplop).
|
5
5
|
|
6
6
|
Install
|
7
7
|
=======
|
8
8
|
|
9
|
-
|
9
|
+
```
|
10
|
+
gem install oplop
|
11
|
+
```
|
10
12
|
|
11
13
|
Usage
|
12
14
|
=====
|
13
15
|
|
14
|
-
|
16
|
+
Oplop and Loplop. Long Oplop defaults to 16 characters and support `<n>*` label
|
17
|
+
prefix for specifying length.
|
18
|
+
|
19
|
+
These will all produce the same password with the new default 16 character length:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
Oplop.password(:master => "master-password", :label => "nickname")
|
23
|
+
Oplop.password(:master => "master-password", :label => "16*nickname")
|
24
|
+
Oplop.password(:master => "master-password", :label => "nickname", :length => 16)
|
25
|
+
```
|
26
|
+
|
27
|
+
These will all produce the same password with the legacy 8 character length:
|
28
|
+
```
|
29
|
+
Oplop.password(:master => "master-password", :label => "*nickname")
|
30
|
+
Oplop.password(:master => "master-password", :label => "8*nickname")
|
31
|
+
Oplop.password(:master => "master-password", :label => "nickname", :length => 8)
|
32
|
+
```
|
33
|
+
|
34
|
+
This is a 20-character password
|
35
|
+
```
|
36
|
+
Oplop.password(:master => "master-password", :label => "20*nickname")
|
37
|
+
```
|
15
38
|
|
16
39
|
CLI
|
17
40
|
===
|
18
41
|
|
19
|
-
This includes an `oplop` program
|
42
|
+
This includes an `oplop` program that defaults to 8 character passwords. And a
|
43
|
+
new `loplop` program that defaults to 16 character passwords.
|
44
|
+
|
45
|
+
Run `oplop --help` for more information.
|
20
46
|
|
21
47
|
License
|
22
48
|
=======
|
data/bin/loplop
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
oplop_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
$LOAD_PATH.unshift(oplop_dir) unless $LOAD_PATH.include?(oplop_dir)
|
4
|
+
|
5
|
+
require 'oplop'
|
6
|
+
require 'oplop/cli'
|
7
|
+
require 'highline/import'
|
8
|
+
require 'optparse'
|
9
|
+
|
10
|
+
# -- exit nicely if control-c
|
11
|
+
Signal.trap("SIGINT") { exit 2 }
|
12
|
+
|
13
|
+
# -- options
|
14
|
+
options = {}
|
15
|
+
optparse = OptionParser.new do |opts|
|
16
|
+
opts.banner = Oplop::Cli.banner
|
17
|
+
|
18
|
+
options[:verbose] = false
|
19
|
+
opts.on( '-v', '--verbose', 'Output the password to STDOUT' ) do
|
20
|
+
options[:verbose] = true
|
21
|
+
end
|
22
|
+
|
23
|
+
options[:new] = false
|
24
|
+
opts.on( '-n', '--new', 'New mode (2 prompt for master)') do
|
25
|
+
options[:new] = true
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
29
|
+
puts opts
|
30
|
+
puts "\n"
|
31
|
+
puts Oplop::Cli.help
|
32
|
+
exit
|
33
|
+
end
|
34
|
+
|
35
|
+
end.parse!
|
36
|
+
|
37
|
+
# -- program
|
38
|
+
label = ARGV.shift
|
39
|
+
|
40
|
+
if label.nil? or label.empty?
|
41
|
+
puts "!! You need to pass in a label!"
|
42
|
+
exit 2
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
master = ask("Enter your master password: ") { |q| q.echo = "*" }
|
47
|
+
|
48
|
+
if options[:new]
|
49
|
+
master_confirm = ask("Enter your master password (again): ") { |q| q.echo = "*" }
|
50
|
+
if (master != master_confirm)
|
51
|
+
puts "!! Your master and confirm don't match!"
|
52
|
+
exit 2
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
password = Oplop.password(:label => label, :master => master)
|
57
|
+
|
58
|
+
if options[:verbose]
|
59
|
+
puts "\n Password for #{label}:\t#{password}\n\n"
|
60
|
+
end
|
61
|
+
|
62
|
+
if Oplop::Cli.copy_to_clipboard(password)
|
63
|
+
print "Your #{label} password has been copied to your clipboard. \n"
|
64
|
+
else
|
65
|
+
print "!! Could not copy to clipboard, try installing xclip. "
|
66
|
+
print "Run with --verbose flag to see password on STDOUT." unless options[:verbose]
|
67
|
+
print "\n"
|
68
|
+
end
|
data/bin/oplop
CHANGED
@@ -53,7 +53,7 @@ if options[:new]
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
password = Oplop.password(:label => label, :master => master)
|
56
|
+
password = Oplop.password(:label => label, :master => master, :length => Oplop::LEGACY_LENGTH)
|
57
57
|
|
58
58
|
if options[:verbose]
|
59
59
|
puts "\n Password for #{label}:\t#{password}\n\n"
|
data/lib/oplop.rb
CHANGED
@@ -1,42 +1,45 @@
|
|
1
1
|
require 'digest/md5'
|
2
2
|
require 'base64'
|
3
3
|
|
4
|
-
|
4
|
+
class Oplop
|
5
|
+
attr_reader :master, :label, :length
|
5
6
|
|
6
|
-
|
7
|
+
LEGACY_LENGTH = 8
|
8
|
+
DEFAULT_LENGTH = 16
|
7
9
|
|
8
|
-
#
|
9
|
-
# Oplop.password(:master => 'p@ssw0rd', :label => 'github')
|
10
|
-
#
|
11
10
|
def self.password(args={})
|
12
|
-
|
13
|
-
|
11
|
+
self.new(args).password
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(args={})
|
15
|
+
@master = args[:master]
|
16
|
+
@label = args[:label]
|
17
|
+
@length = args[:length] || DEFAULT_LENGTH
|
18
|
+
|
19
|
+
if @label =~ /^([0-9]*)?\*/
|
20
|
+
(@length, @label) = @label.split('*')
|
21
|
+
@length = length.to_i
|
22
|
+
@length = LEGACY_LENGTH if length <= 0
|
14
23
|
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
def master_label
|
27
|
+
@master_label ||= '%s%s' % [ master, label ]
|
28
|
+
end
|
29
|
+
|
30
|
+
def password
|
31
|
+
password = Base64.urlsafe_encode64(Digest::MD5.digest(master_label))
|
32
|
+
|
23
33
|
if password.respond_to?(:encode)
|
24
34
|
password = password.encode('UTF-8')
|
25
35
|
end
|
26
|
-
|
36
|
+
|
27
37
|
if m = password.match(/\d+/)
|
28
|
-
password = '%s%s' % [ m[0], password ] if (m.begin(0) >=
|
38
|
+
password = '%s%s' % [ m[0], password ] if (m.begin(0) >= length)
|
29
39
|
else
|
30
40
|
password = '1%s' % password
|
31
41
|
end
|
32
|
-
|
33
|
-
password[0,LENGTH]
|
34
|
-
end
|
35
42
|
|
36
|
-
|
37
|
-
# Ruby 1.8.x does not have this as part of the Base64 lib
|
38
|
-
def self.urlsafe_b64encode(string)
|
39
|
-
Base64.encode64(string).tr('+/', '-_')
|
43
|
+
password[0,length]
|
40
44
|
end
|
41
|
-
|
42
45
|
end
|
data/lib/oplop/cli.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'open3'
|
2
2
|
|
3
|
-
|
3
|
+
class Oplop
|
4
4
|
module Cli
|
5
|
-
|
5
|
+
|
6
6
|
def self.banner
|
7
7
|
"Usage: oplop [OPTIONS] [label]"
|
8
8
|
end
|
@@ -11,14 +11,14 @@ module Oplop
|
|
11
11
|
help = <<-HELP
|
12
12
|
This is a simple cli program to generate oplop passwords.
|
13
13
|
|
14
|
-
You will be prompted for your master password.
|
14
|
+
You will be prompted for your master password.
|
15
15
|
|
16
|
-
The default behavior is to copy the password to your clipboard, and
|
17
|
-
|
18
|
-
|
16
|
+
The default behavior is to copy the password to your clipboard, and not display
|
17
|
+
it. This works if you are on a Mac (and/or have pbcopy installed), or if you
|
18
|
+
have xclip (installed for Linux).
|
19
19
|
|
20
|
-
If you do not have pbcopy or xclip, you will have to run the program
|
21
|
-
|
20
|
+
If you do not have pbcopy or xclip, you will have to run the program in verbose
|
21
|
+
mode (--verbose).
|
22
22
|
|
23
23
|
Here are some examples:
|
24
24
|
|
@@ -31,6 +31,20 @@ Print my gmail password to STDOUT.
|
|
31
31
|
Copy a new password for amazon (prompts for master twice):
|
32
32
|
oplop --new amazon
|
33
33
|
|
34
|
+
NEW: loplop
|
35
|
+
|
36
|
+
There is a new cli program called `loplop`, or long oplop. It will default to
|
37
|
+
passwords of 16 characters. It also has a new UX feature to specify the length:
|
38
|
+
|
39
|
+
loplop <n>*<label>
|
40
|
+
|
41
|
+
Where <n> is how long the password will be. The max is 22 characters. If you
|
42
|
+
start a label with *, it is a short-cut to the legacy length 8 (in other words
|
43
|
+
`8*label` and `*label` will generate the same password).
|
44
|
+
|
45
|
+
See: https://github.com/thedod/loplop
|
46
|
+
|
47
|
+
|
34
48
|
Feedback, patches and bugs: https://github.com/bkaney/oplop
|
35
49
|
HELP
|
36
50
|
end
|
@@ -53,6 +67,6 @@ HELP
|
|
53
67
|
end
|
54
68
|
end
|
55
69
|
end
|
56
|
-
|
70
|
+
|
57
71
|
end
|
58
72
|
end
|
data/lib/oplop/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0
|
1
|
+
class Oplop
|
2
|
+
VERSION = "2.0.0"
|
3
3
|
end
|
data/shippable.yml
ADDED
data/spec/oplop_spec.rb
CHANGED
@@ -2,23 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Oplop do
|
4
4
|
describe ".password" do
|
5
|
-
specify "valid arguments" do
|
6
|
-
expect { Oplop.password(:master => "a", :label => "a") }.not_to raise_error
|
7
|
-
end
|
8
|
-
|
9
|
-
specify "invalid arguments" do
|
10
|
-
expect { Oplop.password }.to raise_error(ArgumentError, /Master and label are required/)
|
11
|
-
end
|
12
|
-
|
13
|
-
specify "invalid arguments" do
|
14
|
-
expect { Oplop.password(:master => "a", :label => "b", :foo => 'c') }.to raise_error(ArgumentError, /Unknown key/)
|
15
|
-
end
|
16
|
-
|
17
5
|
context "tests from testdata.json (see Python implementation at http://code.google.com/p/oplop/)" do
|
18
6
|
# loop around each "case" in testdata.yml
|
19
7
|
Yajl::Parser.new.parse(File.new(File.dirname(__FILE__) + "/testdata.json", 'r')).each do |testdata|
|
20
8
|
specify testdata["why"] do
|
21
|
-
password = Oplop.password(:master => testdata["master"], :label => testdata["label"])
|
9
|
+
password = Oplop.password(:master => testdata["master"], :label => "*" + testdata["label"])
|
10
|
+
expect(password).to eq testdata["password"]
|
11
|
+
|
12
|
+
password = Oplop.password(:master => testdata["master"], :length => 8, :label => testdata["label"])
|
22
13
|
expect(password).to eq testdata["password"]
|
23
14
|
end
|
24
15
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oplop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Kaney
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -70,19 +70,23 @@ description: Provides a ruby library and command line tool for Oplop
|
|
70
70
|
email:
|
71
71
|
- brian@vermonster.com
|
72
72
|
executables:
|
73
|
+
- loplop
|
73
74
|
- oplop
|
74
75
|
extensions: []
|
75
76
|
extra_rdoc_files: []
|
76
77
|
files:
|
77
78
|
- ".gitignore"
|
79
|
+
- ".ruby-version"
|
78
80
|
- Gemfile
|
79
81
|
- README.md
|
80
82
|
- Rakefile
|
83
|
+
- bin/loplop
|
81
84
|
- bin/oplop
|
82
85
|
- lib/oplop.rb
|
83
86
|
- lib/oplop/cli.rb
|
84
87
|
- lib/oplop/version.rb
|
85
88
|
- oplop.gemspec
|
89
|
+
- shippable.yml
|
86
90
|
- spec/oplop_spec.rb
|
87
91
|
- spec/spec_helper.rb
|
88
92
|
- spec/testdata.json
|
@@ -106,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
110
|
version: '0'
|
107
111
|
requirements: []
|
108
112
|
rubyforge_project: oplop
|
109
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.7.3
|
110
114
|
signing_key:
|
111
115
|
specification_version: 4
|
112
116
|
summary: Oplop for Ruby
|