sgpass 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/HISTORY.md +13 -0
  2. data/README.md +27 -5
  3. data/bin/sgpass +44 -5
  4. data/lib/sgpass/version.rb +1 -1
  5. metadata +45 -29
@@ -0,0 +1,13 @@
1
+ v0.1.0 - Aug 03, 2011
2
+ ---------------------
3
+
4
+ ### Changed:
5
+ * Passwords are not shown in the console when prompted.
6
+ * Added the `-c` option to copy the result to clipboard.
7
+ * Passwords are now asked twice for confirmation.
8
+ * Added the `-f` option to just ask for the password once.
9
+
10
+ v0.0.1 - May 09, 2011
11
+ ---------------------
12
+
13
+ Initial release.
data/README.md CHANGED
@@ -4,23 +4,45 @@
4
4
 
5
5
  Install it:
6
6
 
7
- gem install sgpass
7
+ $ gem install sgpass
8
8
 
9
9
  To generate a password for a site, use:
10
10
 
11
- sgpass facebook.com
11
+ $ sgpass facebook.com
12
+ Enter password: [redacted]
13
+ h8GCua3DxC
12
14
 
13
15
  You may even pass full URL's and `sgpass` will figure it out:
14
16
 
15
- sgpass http://www.facebook.com/profile.php
17
+ $ sgpass http://www.facebook.com/profile.php
18
+ Enter password: [redacted]
19
+ h8GCua3DxC
16
20
 
17
21
  ...These will prompt you for your master password. If you want to do it
18
22
  straight from the command line:
19
23
 
20
- sgpass facebook.com MyPassword
24
+ $ sgpass facebook.com MyPassword
25
+ h8GCua3DxC
21
26
 
22
27
  Or from your Ruby app, you may:
23
28
 
24
29
  ```ruby
25
- SGPass.generate('hunter2', 'http://www.facebook.com')
30
+ require 'sgpass'
31
+ str = SGPass.generate('hunter2', 'http://www.facebook.com') #=> "vXzettvkI2"
26
32
  ```
33
+
34
+ ## Tips and tricks
35
+
36
+ In Mac OSX, you pipe it to `pbcopy` to copy the password to the clipboard.
37
+
38
+ $ sgpass facebook.com | pbcopy
39
+
40
+ Or on Linux:
41
+
42
+ $ sgpass facebook.com | xsel -b -i
43
+
44
+ ## Acknowledgements
45
+
46
+ Gem by [Rico Sta. Cruz](http://www.ricostacruz.com), based on the original
47
+ [supergenpass.com](http://www.supergenpass.com) JavaScript version.
48
+
data/bin/sgpass CHANGED
@@ -1,16 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.expand_path('../../lib/sgpass', __FILE__)
3
+ require 'highline'
3
4
 
4
5
  def print_usage(options={})
5
6
  full = options[:full]
6
7
  cmd = options[:cmd] || File.basename($0)
7
8
 
8
- $stderr.write "Usage: #{cmd} URL [PASSWORD]\n"
9
+ $stderr.write "Usage: #{cmd} URL [PASSWORD] [-c] [-f]\n"
9
10
  if full
10
11
  $stderr.write "\n"
11
12
  $stderr.write "Generates a site-specific password for the given URL and master password.\n"
12
13
  $stderr.write "If no password is given, you will be prompted for one.\n"
13
14
  $stderr.write "\n"
15
+ $stderr.write "Options:\n"
16
+ $stderr.write " -c, --copy Copies the result to the clipboard."
17
+ $stderr.write " -f, --fast Prompts password just once instead of twice."
18
+ $stderr.write "\n"
14
19
  $stderr.write "Examples:\n"
15
20
  $stderr.write " #{cmd} twitter.com\n"
16
21
  $stderr.write " #{cmd} facebook.com HelloThere20\n"
@@ -18,15 +23,49 @@ def print_usage(options={})
18
23
  end
19
24
  end
20
25
 
26
+ $options = {
27
+ :copy => ARGV.delete('-c') || ARGV.delete('--copy'),
28
+ :fast => ARGV.delete('-f') || ARGV.delete('--fast'),
29
+ }
30
+
31
+ def output(str)
32
+ if $options[:copy]
33
+ require 'clipboard'
34
+ Clipboard.copy str
35
+ $stderr.write "Done. Your password is in the clipboard.\n"
36
+ else
37
+ puts str
38
+ end
39
+ end
40
+
41
+ def ask_passwd
42
+ ask = lambda { |message| HighLine.new.ask(message) { |q| q.echo = '*' } }
43
+
44
+ if $options[:fast]
45
+ ask.call "Password: "
46
+ else
47
+ one = 0
48
+ two = nil
49
+
50
+ while one != two
51
+ $stderr.write "Passwords don't match. Try again.\n\n" if one != 0
52
+
53
+ one = ask.call "Password: "
54
+ two = ask.call "Repeat: "
55
+ end
56
+
57
+ one
58
+ end
59
+ end
60
+
21
61
  if ARGV == ['--help'] || ARGV == ['-h'] || ARGV.empty?
22
62
  print_usage :full => true
23
63
 
24
64
  elsif ARGV.size == 1
25
65
  uri, _ = ARGV
26
- $stderr.write "Password: "
27
- passwd = STDIN.readline.strip
66
+ passwd = ask_passwd
28
67
 
29
- puts SGPass.generate(passwd, uri)
68
+ output SGPass.generate(passwd, uri)
30
69
 
31
70
  elsif ARGV.size != 2
32
71
  print_usage
@@ -34,5 +73,5 @@ elsif ARGV.size != 2
34
73
 
35
74
  else
36
75
  uri, passwd = ARGV
37
- puts SGPass.generate(passwd, uri)
76
+ output SGPass.generate(passwd, uri)
38
77
  end
@@ -1,5 +1,5 @@
1
1
  module SGPass
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
 
4
4
  def self.version
5
5
  VERSION
metadata CHANGED
@@ -1,60 +1,76 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sgpass
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
4
5
  prerelease:
5
- version: 0.0.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Rico Sta. Cruz
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-10 00:00:00 +08:00
12
+ date: 2011-08-03 00:00:00.000000000 +08:00
14
13
  default_executable:
15
- dependencies: []
16
-
17
- description: SGPass uses a hash algorithm to transform a master password into unique, complex passwords for the Web sites you visit. This is a Ruby port of www.supergenpass.com.
18
- email:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: highline
17
+ requirement: &2153248760 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 1.6.2
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2153248760
26
+ - !ruby/object:Gem::Dependency
27
+ name: clipboard
28
+ requirement: &2153248260 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.9
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *2153248260
37
+ description: SGPass uses a hash algorithm to transform a master password into unique,
38
+ complex passwords for the Web sites you visit. This is a Ruby port of www.supergenpass.com.
39
+ email:
19
40
  - rico@sinefunc.com
20
- executables:
41
+ executables:
21
42
  - sgpass
22
43
  extensions: []
23
-
24
44
  extra_rdoc_files: []
25
-
26
- files:
45
+ files:
27
46
  - lib/sgpass/version.rb
28
47
  - lib/sgpass.rb
29
48
  - bin/sgpass
49
+ - HISTORY.md
30
50
  - README.md
31
51
  has_rdoc: true
32
52
  homepage: http://github.com/rstacruz/sgpass
33
53
  licenses: []
34
-
35
54
  post_install_message:
36
55
  rdoc_options: []
37
-
38
- require_paths:
56
+ require_paths:
39
57
  - lib
40
- required_ruby_version: !ruby/object:Gem::Requirement
58
+ required_ruby_version: !ruby/object:Gem::Requirement
41
59
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
46
- required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
65
  none: false
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
52
70
  requirements: []
53
-
54
71
  rubyforge_project:
55
72
  rubygems_version: 1.6.2
56
73
  signing_key:
57
74
  specification_version: 3
58
75
  summary: Password generator based on hash algorithms.
59
76
  test_files: []
60
-