uhide 0.0.24 โ†’ 0.0.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/bin/uhide +4 -8
  4. data/lib/uhide/main.rb +127 -131
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de4c2b54e1230468ca0a0318f99ab31a9dddd1d1631dce3aa3f551d79e2dd26c
4
- data.tar.gz: 52e22998bd9e41bb09d9752e8afc9e25d1a88bc5bd2296da9619baccb8dcd6f0
3
+ metadata.gz: b1bb0a47cafba2fee10332891e6be453113a5b1ceae61eba210d77605b199083
4
+ data.tar.gz: 4c6b59d2d8ccc634767340ca5a395d6478fb3c2548c8a525576b01d7698fa834
5
5
  SHA512:
6
- metadata.gz: 974c964b05b157299b7d4767377478ee8c7c86efbcaf04c3510fd96b97736c51b9a0ed5b7b59c17ca6c65e2bafff3a2534c41a911a018385d89231fbd2e1725a
7
- data.tar.gz: 6554881866d82efa6472c848aecb2a6ed5187982672885c7de5848bdc371a661f920638ab0ca694217b2881953063d512d4e43df2750bb745a7cdbafbaa2ba9e
6
+ metadata.gz: fc10019a4bcc6bb68172f8a69d1917c18f217fb640b5fe640beda754695f3e4feee234f618eb318070ab4e72923e1576cc81f70196684e6859cd778ad03961b9
7
+ data.tar.gz: d42ea00c9827ab34834c732f67c9e2758dc7ddf67914cd487c08531837d2f13eb5e235f99b9144cae39b90b86f21bcec6ba932b25ca5a5dadb4193bb807dd468
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ๐Ÿ…ฟ๏ธ๐Ÿ˜๐Ÿ‡ผeยฎ๏ธed    ๐Ÿ…ฑ๏ธ๐Ÿ‡พ    eโ“‚๏ธ๐Ÿค“๐Ÿ‡ฏโ„น๏ธ    tec๐Ÿจn๐Ÿ˜Ž๐Ÿ‡ฑ๐Ÿ…พ๏ธg๐Ÿ‡พ
4
4
 
5
- Store passwords, phone numbers, email addresses, credit card numbers -- any sensitive text.
5
+ Securely store passwords, phone numbers, email addresses, credit card numbers -- any sensitive text.
6
6
 
7
7
  **Install:** `gem install uhide`
8
8
 
data/bin/uhide CHANGED
@@ -1,11 +1,8 @@
1
1
  require 'optparse'
2
2
  require 'uhide'
3
3
 
4
- options = {}
5
- OptionParser.new do |opts|
6
- opts.banner = "Usage: uhide command [key-name] [key-value]"
7
-
8
- opts.on("-h", "--help", "Help") do |v|
4
+ OptionParser.new do |๐Ÿ“‹|
5
+ ๐Ÿ“‹.on('-h', '--help', 'Help') do |๐Ÿ“š|
9
6
  puts <<-HELP
10
7
  Usage: uhide command [key-name] [key-value]
11
8
  Example: uhide set gmail mysecurepassword123
@@ -14,17 +11,16 @@ Example: uhide get gmail
14
11
  Get Started:
15
12
 
16
13
  1. run `uhide`
17
- 2. You will be see: ๐Ÿ”‘ > . Choose a password you can remember and enter it.
14
+ 2. You will see: ๐Ÿ”‘ > . Choose a password you can remember and enter it.
18
15
  3. You can now run commands. Next time you run `uhide` from this directory, enter the same password to manage your sensitive information.
19
16
 
20
17
  Commands and Optional Arguments:
21
18
  - get [key-name]
22
19
  - set [key-name] [key-value]
23
-
24
20
  HELP
25
21
  exit!
26
22
  end
27
23
 
28
24
  end.parse!
29
25
 
30
- Uhide::Main.start()
26
+ Uhide::Main.โœˆ๏ธ
data/lib/uhide/main.rb CHANGED
@@ -1,153 +1,150 @@
1
- $โ˜” = " โ˜” > "
2
- $๐Ÿ”‘ = " ๐Ÿ”‘ > "
3
- $๐Ÿง‚ = -> { ๐Ÿ—ƒ๏ธ '๐Ÿง‚', SecureRandom.random_bytes }
4
- $๐Ÿ“ = -> { ๐Ÿ—ƒ๏ธ '๐Ÿ“', ActiveSupport::MessageEncryptor.key_len }
5
- INVALID_KEY = 'invalid key'.colorize(:magenta)
6
- UNSUPPORTED_๐Ÿ‘พ = 'unsupported'.colorize(:magenta) + ' ๐Ÿ‘พ'
7
- $cache = {}
1
+ โ€ผ๏ธ๐Ÿ”‘ = 'invalid key'.colorize(:magenta)
2
+ โ€ผ๏ธ๐Ÿ‘พ = 'unsupported'.colorize(:magenta) + ' ๐Ÿ‘พ'
8
3
 
9
- def password?
10
- ๐Ÿงผ STDIN.noecho(&:gets)
11
- end
12
-
13
- def ๐Ÿšฝ
14
- print "\r"
15
- $stdout.flush
16
- end
17
-
18
- def โ“ ๐Ÿ”‘, simple: true
19
- print ๐Ÿ”‘
20
- password = password?
21
- $password = password if simple
22
- ๐Ÿšฝ
23
- return password
24
- end
25
-
26
- def ๐Ÿงผ ๐Ÿ—‘๏ธ
27
- ๐Ÿ—‘๏ธ.chomp
28
- end
29
-
30
- def ๐Ÿ”“ ๐Ÿท๏ธ: nil
31
- if ๐Ÿท๏ธ.nil?
32
- puts $cache['ddllv']
33
- else
34
- puts $cache['ddllv'][๐Ÿท๏ธ]
35
- end
36
-
37
- ๐Ÿ“• = File.read './๐Ÿง‚'
38
- if ๐Ÿ“•.empty?
39
- ๐Ÿ”€ = SecureRandom.random_bytes $๐Ÿ“.call
40
- File.write './๐Ÿง‚', Marshal.dump(๐Ÿ”€)
41
- return $cache['๐Ÿง‚'] = ๐Ÿ”€
42
- else
43
- return $cache['๐Ÿง‚'] = Marshal.load(File.read './๐Ÿง‚')
44
- end
45
-
46
- end
47
-
48
- def ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
49
- $cache['ddllv'][๐Ÿท๏ธ] = ๐Ÿ’Ž
50
- ๐Ÿ’พ
51
- end
52
-
53
- def ๐Ÿค– ๐Ÿ—ฃ๏ธ
54
- ๐Ÿ‘พ, ๐Ÿท๏ธ, ๐Ÿ’Ž = ๐Ÿ—ฃ๏ธ.split
55
-
56
- if ๐Ÿ‘พ.nil?
57
- return
58
- end
4
+ class Uhide::Main
5
+ @@โ˜” = " โ˜” > "
6
+ @@๐Ÿ”‘ = " ๐Ÿ”‘ > "
7
+ @@๐Ÿ—„๏ธ = {}
59
8
 
60
- case ๐Ÿ‘พ.to_sym
61
- when :get
62
- if ๐Ÿท๏ธ
63
- ๐Ÿ”“ ๐Ÿท๏ธ: ๐Ÿท๏ธ
64
- else
65
- ๐Ÿ”“
9
+ class << self
10
+ def ๐Ÿง‚
11
+ ๐Ÿ—ƒ๏ธ '๐Ÿง‚', SecureRandom.random_bytes
66
12
  end
67
13
 
68
- when :set
69
- ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
14
+ def ๐Ÿ“
15
+ ๐Ÿ—ƒ๏ธ '๐Ÿ“', ActiveSupport::MessageEncryptor.key_len
16
+ end
70
17
 
71
- when :exit
72
- exit!
18
+ def ๐Ÿšฝ
19
+ print "\r"
20
+ $stdout.flush
21
+ end
73
22
 
74
- when :reset
75
- if โ“($๐Ÿ”‘, simple: false) == $password
76
- ['ddllv', '๐Ÿง‚', '๐Ÿ“'].each_entry{ |item| File.delete "./#{item}" }
77
- exit!
78
- else
79
- puts INVALID_KEY
23
+ def ๐Ÿงผ ๐Ÿ—‘๏ธ
24
+ ๐Ÿ—‘๏ธ.chomp
80
25
  end
81
26
 
82
- else
83
- puts UNSUPPORTED_๐Ÿ‘พ
84
- end
85
-
86
- end
87
-
88
- def ๐Ÿ’พ
89
- โš›๏ธ = ActiveSupport::MessageEncryptor.new(
90
- ActiveSupport::KeyGenerator.new($password).generate_key($๐Ÿง‚.call, $๐Ÿ“.call)
91
- )
92
-
93
- was_bootstrapped = !(not $cache['ddllv'])
94
- ๐Ÿ“– = ๐Ÿ—ƒ๏ธ 'ddllv', {}, โš›๏ธ: โš›๏ธ
95
- ๐Ÿ“€ 'ddllv', ๐Ÿ“–, โš›๏ธ: โš›๏ธ if was_bootstrapped
96
- end
97
-
98
- def ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ“–, โš›๏ธ: false
99
- if โš›๏ธ
100
- ๐Ÿ“• = โš›๏ธ.encrypt_and_sign ๐Ÿ“–
101
- else
102
- ๐Ÿ“• = ๐Ÿ“–
103
- end
104
-
105
- ๐Ÿ“• = Marshal.dump ๐Ÿ“•
106
- File.write "./#{๐Ÿ—‚๏ธ}", ๐Ÿ“•
107
- return ๐Ÿ“•
108
- end
109
-
110
- def ๐Ÿ—ƒ๏ธ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: false
111
- if $cache[๐Ÿ—‚๏ธ]
112
- return $cache[๐Ÿ—‚๏ธ]
113
- end
114
-
115
- begin
116
- ๐Ÿ“• = File.read "./#{๐Ÿ—‚๏ธ}"
117
- rescue Errno::ENOENT
118
- ๐Ÿ“• = ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: โš›๏ธ
119
- end
120
-
121
- if not ๐Ÿ“•.empty?
122
- ๐Ÿ“• = Marshal.load ๐Ÿ“•
27
+ def โ“ ๐Ÿ”‘, simple: true
28
+ print ๐Ÿ”‘
29
+ โœ๏ธ = ๐Ÿงผ STDIN.noecho(&:gets)
30
+ @@โœ๏ธ = โœ๏ธ if simple
31
+ ๐Ÿšฝ
32
+ return โœ๏ธ
33
+ end
123
34
 
124
- if โš›๏ธ
35
+ def ๐Ÿ”“ ๐Ÿท๏ธ: nil
36
+ if ๐Ÿท๏ธ.nil?
37
+ puts @@๐Ÿ—„๏ธ['ใ€ฝ๏ธ']
38
+ else
39
+ puts @@๐Ÿ—„๏ธ['ใ€ฝ๏ธ'][๐Ÿท๏ธ]
40
+ end
41
+
42
+ end
43
+
44
+ def ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
45
+ @@๐Ÿ—„๏ธ['ใ€ฝ๏ธ'][๐Ÿท๏ธ] = ๐Ÿ’Ž
46
+ ๐Ÿ’พ
47
+ end
48
+
49
+ def ๐Ÿ’พ
50
+ โš›๏ธ = ActiveSupport::MessageEncryptor.new(
51
+ ActiveSupport::KeyGenerator.new(@@โœ๏ธ).generate_key(๐Ÿง‚, ๐Ÿ“)
52
+ )
53
+
54
+ ๐Ÿฅพ = !(not @@๐Ÿ—„๏ธ['ใ€ฝ๏ธ'])
55
+ ๐Ÿ“– = ๐Ÿ—ƒ๏ธ 'ใ€ฝ๏ธ', {}, โš›๏ธ: โš›๏ธ
56
+ ๐Ÿ“€ 'ใ€ฝ๏ธ', ๐Ÿ“–, โš›๏ธ: โš›๏ธ if ๐Ÿฅพ
57
+ end
58
+
59
+ def ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ“–, โš›๏ธ: false
60
+ if โš›๏ธ
61
+ ๐Ÿ“• = โš›๏ธ.encrypt_and_sign ๐Ÿ“–
62
+ else
63
+ ๐Ÿ“• = ๐Ÿ“–
64
+ end
65
+
66
+ ๐Ÿ“• = Marshal.dump ๐Ÿ“•
67
+ File.write "./#{๐Ÿ—‚๏ธ}", ๐Ÿ“•
68
+ return ๐Ÿ“•
69
+ end
70
+
71
+ def ๐Ÿ—ƒ๏ธ ๐Ÿ—‚๏ธ, ๐Ÿ’Ž, โš›๏ธ: false
72
+ if @@๐Ÿ—„๏ธ[๐Ÿ—‚๏ธ]
73
+ return @@๐Ÿ—„๏ธ[๐Ÿ—‚๏ธ]
74
+ end
75
+
125
76
  begin
126
- ๐Ÿ“– = โš›๏ธ.decrypt_and_verify ๐Ÿ“•
127
- rescue ActiveSupport::MessageVerifier::InvalidSignature
128
- puts INVALID_KEY
77
+ ๐Ÿ“• = File.read "./#{๐Ÿ—‚๏ธ}"
78
+ rescue Errno::ENOENT
79
+ ๐Ÿ“• = ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ’Ž, โš›๏ธ: โš›๏ธ
80
+ end
81
+
82
+ if not ๐Ÿ“•.empty?
83
+ ๐Ÿ“• = Marshal.load ๐Ÿ“•
84
+
85
+ if โš›๏ธ
86
+ begin
87
+ ๐Ÿ“– = โš›๏ธ.decrypt_and_verify ๐Ÿ“•
88
+ rescue ActiveSupport::MessageVerifier::InvalidSignature
89
+ puts โ€ผ๏ธ๐Ÿ”‘
90
+ exit!
91
+ end
92
+
93
+ else
94
+ ๐Ÿ“– = ๐Ÿ“•
95
+ end
96
+
97
+ end
98
+
99
+ return @@๐Ÿ—„๏ธ[๐Ÿ—‚๏ธ] = ๐Ÿ“–
100
+ end
101
+
102
+ def ๐Ÿค– ๐Ÿ—ฃ๏ธ
103
+ ๐Ÿ‘พ, ๐Ÿท๏ธ, ๐Ÿ’Ž = ๐Ÿ—ฃ๏ธ.split
104
+
105
+ if ๐Ÿ‘พ.nil?
106
+ return
107
+ end
108
+
109
+ case ๐Ÿ‘พ.to_sym
110
+ when :get
111
+ if ๐Ÿท๏ธ
112
+ ๐Ÿ”“ ๐Ÿท๏ธ: ๐Ÿท๏ธ
113
+ else
114
+ ๐Ÿ”“
115
+ end
116
+
117
+ when :set
118
+ ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
119
+
120
+ when :exit, :quit
129
121
  exit!
122
+
123
+ when :help
124
+ puts "For help, quit and run `uhide -h` from your shell"
125
+
126
+ when :reset
127
+ if โ“(@@๐Ÿ”‘, simple: false) == @@โœ๏ธ
128
+ ['ใ€ฝ๏ธ', '๐Ÿง‚', '๐Ÿ“'].each_entry { |item| File.delete "./#{item}" }
129
+ exit!
130
+ else
131
+ puts โ€ผ๏ธ๐Ÿ”‘
132
+ end
133
+
134
+ else
135
+ puts โ€ผ๏ธ๐Ÿ‘พ
130
136
  end
131
137
 
132
- else
133
- ๐Ÿ“– = ๐Ÿ“•
134
138
  end
135
139
 
136
- end
137
-
138
- return $cache[๐Ÿ—‚๏ธ] = ๐Ÿ“–
139
- end
140
-
141
- class Uhide::Main
142
- class << self
143
- def start()
140
+ def โœˆ๏ธ
144
141
  begin
145
- โ“ $๐Ÿ”‘
142
+ โ“ @@๐Ÿ”‘
146
143
 
147
144
  ๐Ÿ’พ
148
145
 
149
146
  loop do
150
- print $โ˜”
147
+ print @@โ˜”
151
148
  ๐Ÿค–(๐Ÿงผ gets)
152
149
  end
153
150
 
@@ -161,4 +158,3 @@ class Uhide::Main
161
158
  end
162
159
 
163
160
  end
164
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uhide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Keen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-15 00:00:00.000000000 Z
11
+ date: 2021-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport