uhide 0.0.2 โ†’ 0.0.7

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -0
  3. data/bin/uhide +2 -3
  4. data/lib/uhide.rb +2 -150
  5. data/lib/uhide/main.rb +162 -0
  6. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84d709066acff1d94e19913085846da8d79af5a6e082df4df3c4ee65ce02464e
4
- data.tar.gz: 7e9ea43da436d2cfe163b00c2ab7acc8e095397daa5dc987d3ee0412c3724087
3
+ metadata.gz: 8a8fd79cc30cb4eff3b0da4798c5d9c72557148d5bd004b74b359acd39ee08ac
4
+ data.tar.gz: f4f931d8f2c0ff7ac55fe3d90ec53a0e6840d6e08dcf1678758a0bdaa00e353e
5
5
  SHA512:
6
- metadata.gz: b19cc6cb61384179806366afc34fbef80385cdc75375a899a5320376109bb78b3a57b6add16606eaeb46a95520841c72c5a649a738f752d4044c7e98a6ef020e
7
- data.tar.gz: bd210c009668cad2a5b2f0612e9a131c57377e09f2cf6befe27f416696b2c5bcaed1415a3fab6d47289f7fdfcea480a58883d1d667d8f52c278c66de915572ef
6
+ metadata.gz: 2d70fd766f4d9ec4a4d3509f41f2e1928be482bfad85295fa02441c015dcdb4c4a00aaae0fba30541c233c4c5582059c74472d6c196f16c14316159e6f8acd6b
7
+ data.tar.gz: 6a687531e01bc123603183ade8e25c183702057bd6fd0c2a3fc891179fe8045477de3a389a0b7a23cdbf2ca40358a5ae5fc06c19adb0b28d9cf3ffe63fa32c58
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # โ˜” uhide
2
+
3
+ ๐Ÿ…ฟ๏ธ๐Ÿ˜๐Ÿ‡ผeยฎ๏ธed     ๐Ÿ…ฑ๏ธ๐Ÿ‡พ    eโ“‚๏ธ๐Ÿค“๐Ÿ‡ฏโ„น๏ธ    tec๐Ÿจn๐Ÿ˜Ž๐Ÿ‡ฑ๐Ÿ…พ๏ธg๐Ÿ‡พ | ๐Ÿ•ต๏ธ Personal encryption fit for a spy
4
+
5
+ Store passwords, phone numbers, email addresses, credit card numbers -- any sensitive text.
6
+
7
+ **Install:** `gem install uhide`
8
+
9
+ **Usage**: `โ˜” --help`
10
+
11
+ ISC (BSD 2 / MIT)
12
+
data/bin/uhide CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env ruby
2
-
3
- include 'uhide.rb'
1
+ require 'uhide'
4
2
 
3
+ Uhide::Main.start()
data/lib/uhide.rb CHANGED
@@ -1,153 +1,5 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'yaml'
4
- require 'io/console'
5
- require 'securerandom'
6
-
7
- Bundler.require(:default)
8
-
9
-
10
- โ˜” = " โ˜” > "
11
- $๐Ÿ”‘ = " ๐Ÿ”‘ > "
12
- $๐Ÿง‚ = (lambda { ๐Ÿ—ƒ๏ธ '๐Ÿง‚', SecureRandom.random_bytes })
13
- $๐Ÿ“ = lambda { ๐Ÿ—ƒ๏ธ '๐Ÿ“', ActiveSupport::MessageEncryptor.key_len }
14
- INVALID_KEY = 'invalid key'.colorize(:red)
15
- $cache = {}
16
-
17
- def password?
18
- ๐Ÿงผ STDIN.noecho(&:gets)
19
- end
20
-
21
- def ๐Ÿšฝ
22
- print "\r"
23
- $stdout.flush
24
- end
25
-
26
- def โ“ ๐Ÿ”‘, simple: true
27
- print ๐Ÿ”‘
28
- password = password?
29
- $password = password if simple
30
- ๐Ÿšฝ
31
- return password
32
- end
33
-
34
- def ๐Ÿงผ ๐Ÿ—‘๏ธ
35
- ๐Ÿ—‘๏ธ.chomp
36
- end
37
-
38
- def ๐Ÿ”“ ๐Ÿท๏ธ: nil
39
- if ๐Ÿท๏ธ.nil?
40
- puts $cache['ddllv']
41
- else
42
- puts $cache['ddllv'][๐Ÿท๏ธ]
43
- end
44
-
45
- ๐Ÿ“• = File.read './๐Ÿง‚'
46
- if ๐Ÿ“•.empty?
47
- ๐Ÿ”€ = SecureRandom.random_bytes $๐Ÿ“.call
48
- File.write './๐Ÿง‚', Marshal.dump(๐Ÿ”€)
49
- return $cache['๐Ÿง‚'] = ๐Ÿ”€
50
- else
51
- return $cache['๐Ÿง‚'] = Marshal.load(File.read './๐Ÿง‚')
52
- end
53
-
54
- end
55
-
56
- def ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
57
- $cache['ddllv'][๐Ÿท๏ธ] = ๐Ÿ’Ž
58
- ๐Ÿ’พ
59
- end
60
-
61
- def ๐Ÿค– ๐Ÿ—ฃ๏ธ
62
- ๐Ÿ‘พ, ๐Ÿท๏ธ, ๐Ÿ’Ž = ๐Ÿ—ฃ๏ธ.split
63
-
64
- case ๐Ÿ‘พ.to_sym
65
- when :get
66
- if ๐Ÿท๏ธ
67
- ๐Ÿ”“ ๐Ÿท๏ธ: ๐Ÿท๏ธ
68
- else
69
- ๐Ÿ”“
70
- end
71
-
72
- when :set
73
- ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
74
-
75
- when :reset
76
- if โ“($๐Ÿ”‘, simple: false) == $password
77
- ['ddllv', '๐Ÿง‚', '๐Ÿ“'].each_entry{ |item| File.delete "./#{item}" }
78
- exit!
79
- else
80
- puts INVALID_KEY
81
- end
82
-
83
- end
84
-
85
- end
86
-
87
- def ๐Ÿ’พ
88
- โš›๏ธ = ActiveSupport::MessageEncryptor.new(
89
- ActiveSupport::KeyGenerator.new($password).generate_key($๐Ÿง‚.call, $๐Ÿ“.call)
90
- )
1
+ module Uhide
91
2
 
92
- was_bootstrapped = !(not $cache['ddllv'])
93
- ๐Ÿ“– = ๐Ÿ—ƒ๏ธ 'ddllv', {}, โš›๏ธ: โš›๏ธ
94
- ๐Ÿ“€ 'ddllv', ๐Ÿ“–, โš›๏ธ: โš›๏ธ if was_bootstrapped
95
3
  end
96
4
 
97
- def ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ“–, โš›๏ธ: false
98
- if โš›๏ธ
99
- ๐Ÿ“• = โš›๏ธ.encrypt_and_sign ๐Ÿ“–
100
- else
101
- ๐Ÿ“• = ๐Ÿ“–
102
- end
103
-
104
- ๐Ÿ“• = Marshal.dump(๐Ÿ“•)
105
- File.write "./#{๐Ÿ—‚๏ธ}", ๐Ÿ“•
106
- return ๐Ÿ“•
107
- end
108
-
109
- def ๐Ÿ—ƒ๏ธ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: false
110
- if $cache[๐Ÿ—‚๏ธ]
111
- return $cache[๐Ÿ—‚๏ธ]
112
- end
113
-
114
- begin
115
- ๐Ÿ“• = File.read "./#{๐Ÿ—‚๏ธ}"
116
- rescue Errno::ENOENT
117
- ๐Ÿ“• = ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: โš›๏ธ
118
- end
119
-
120
- if not ๐Ÿ“•.empty?
121
- ๐Ÿ“• = Marshal.load ๐Ÿ“•
122
-
123
- if โš›๏ธ
124
- begin
125
- ๐Ÿ“– = โš›๏ธ.decrypt_and_verify ๐Ÿ“•
126
- rescue ActiveSupport::MessageVerifier::InvalidSignature
127
- puts INVALID_KEY
128
- exit!
129
- end
130
-
131
- else
132
- ๐Ÿ“– = ๐Ÿ“•
133
- end
134
-
135
- end
136
-
137
- return $cache[๐Ÿ—‚๏ธ] = ๐Ÿ“–
138
- end
139
-
140
- begin
141
- โ“ $๐Ÿ”‘
142
-
143
- ๐Ÿ’พ
144
-
145
- loop do
146
- print โ˜”
147
- ๐Ÿค–(๐Ÿงผ gets)
148
- end
149
-
150
- rescue SystemExit, Interrupt
151
- ๐Ÿšฝ
152
- exit!
153
- end
5
+ require_relative "uhide/main"
data/lib/uhide/main.rb ADDED
@@ -0,0 +1,162 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'yaml'
4
+ require 'io/console'
5
+ require 'securerandom'
6
+
7
+ Bundler.require(:default)
8
+
9
+ โ˜” = " โ˜” > "
10
+ $๐Ÿ”‘ = " ๐Ÿ”‘ > "
11
+ $๐Ÿง‚ = (lambda { ๐Ÿ—ƒ๏ธ '๐Ÿง‚', SecureRandom.random_bytes })
12
+ $๐Ÿ“ = lambda { ๐Ÿ—ƒ๏ธ '๐Ÿ“', ActiveSupport::MessageEncryptor.key_len }
13
+ INVALID_KEY = 'invalid key'.colorize(:red)
14
+ $cache = {}
15
+
16
+ def password?
17
+ ๐Ÿงผ STDIN.noecho(&:gets)
18
+ end
19
+
20
+ def ๐Ÿšฝ
21
+ print "\r"
22
+ $stdout.flush
23
+ end
24
+
25
+ def โ“ ๐Ÿ”‘, simple: true
26
+ print ๐Ÿ”‘
27
+ password = password?
28
+ $password = password if simple
29
+ ๐Ÿšฝ
30
+ return password
31
+ end
32
+
33
+ def ๐Ÿงผ ๐Ÿ—‘๏ธ
34
+ ๐Ÿ—‘๏ธ.chomp
35
+ end
36
+
37
+ def ๐Ÿ”“ ๐Ÿท๏ธ: nil
38
+ if ๐Ÿท๏ธ.nil?
39
+ puts $cache['ddllv']
40
+ else
41
+ puts $cache['ddllv'][๐Ÿท๏ธ]
42
+ end
43
+
44
+ ๐Ÿ“• = File.read './๐Ÿง‚'
45
+ if ๐Ÿ“•.empty?
46
+ ๐Ÿ”€ = SecureRandom.random_bytes $๐Ÿ“.call
47
+ File.write './๐Ÿง‚', Marshal.dump(๐Ÿ”€)
48
+ return $cache['๐Ÿง‚'] = ๐Ÿ”€
49
+ else
50
+ return $cache['๐Ÿง‚'] = Marshal.load(File.read './๐Ÿง‚')
51
+ end
52
+
53
+ end
54
+
55
+ def ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
56
+ $cache['ddllv'][๐Ÿท๏ธ] = ๐Ÿ’Ž
57
+ ๐Ÿ’พ
58
+ end
59
+
60
+ def ๐Ÿค– ๐Ÿ—ฃ๏ธ
61
+ ๐Ÿ‘พ, ๐Ÿท๏ธ, ๐Ÿ’Ž = ๐Ÿ—ฃ๏ธ.split
62
+
63
+ case ๐Ÿ‘พ.to_sym
64
+ when :get
65
+ if ๐Ÿท๏ธ
66
+ ๐Ÿ”“ ๐Ÿท๏ธ: ๐Ÿท๏ธ
67
+ else
68
+ ๐Ÿ”“
69
+ end
70
+
71
+ when :set
72
+ ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
73
+
74
+ when :reset
75
+ if โ“($๐Ÿ”‘, simple: false) == $password
76
+ ['ddllv', '๐Ÿง‚', '๐Ÿ“'].each_entry{ |item| File.delete "./#{item}" }
77
+ exit!
78
+ else
79
+ puts INVALID_KEY
80
+ end
81
+
82
+ end
83
+
84
+ end
85
+
86
+ def ๐Ÿ’พ
87
+ โš›๏ธ = ActiveSupport::MessageEncryptor.new(
88
+ ActiveSupport::KeyGenerator.new($password).generate_key($๐Ÿง‚.call, $๐Ÿ“.call)
89
+ )
90
+
91
+ was_bootstrapped = !(not $cache['ddllv'])
92
+ ๐Ÿ“– = ๐Ÿ—ƒ๏ธ 'ddllv', {}, โš›๏ธ: โš›๏ธ
93
+ ๐Ÿ“€ 'ddllv', ๐Ÿ“–, โš›๏ธ: โš›๏ธ if was_bootstrapped
94
+ end
95
+
96
+ def ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ“–, โš›๏ธ: false
97
+ if โš›๏ธ
98
+ ๐Ÿ“• = โš›๏ธ.encrypt_and_sign ๐Ÿ“–
99
+ else
100
+ ๐Ÿ“• = ๐Ÿ“–
101
+ end
102
+
103
+ ๐Ÿ“• = Marshal.dump(๐Ÿ“•)
104
+ File.write "./#{๐Ÿ—‚๏ธ}", ๐Ÿ“•
105
+ return ๐Ÿ“•
106
+ end
107
+
108
+ def ๐Ÿ—ƒ๏ธ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: false
109
+ if $cache[๐Ÿ—‚๏ธ]
110
+ return $cache[๐Ÿ—‚๏ธ]
111
+ end
112
+
113
+ begin
114
+ ๐Ÿ“• = File.read "./#{๐Ÿ—‚๏ธ}"
115
+ rescue Errno::ENOENT
116
+ ๐Ÿ“• = ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: โš›๏ธ
117
+ end
118
+
119
+ if not ๐Ÿ“•.empty?
120
+ ๐Ÿ“• = Marshal.load ๐Ÿ“•
121
+
122
+ if โš›๏ธ
123
+ begin
124
+ ๐Ÿ“– = โš›๏ธ.decrypt_and_verify ๐Ÿ“•
125
+ rescue ActiveSupport::MessageVerifier::InvalidSignature
126
+ puts INVALID_KEY
127
+ exit!
128
+ end
129
+
130
+ else
131
+ ๐Ÿ“– = ๐Ÿ“•
132
+ end
133
+
134
+ end
135
+
136
+ return $cache[๐Ÿ—‚๏ธ] = ๐Ÿ“–
137
+ end
138
+
139
+ class Uhide::Main
140
+ class << self
141
+ def start()
142
+ begin
143
+ โ“ $๐Ÿ”‘
144
+
145
+ ๐Ÿ’พ
146
+
147
+ loop do
148
+ print โ˜”
149
+ ๐Ÿค–(๐Ÿงผ gets)
150
+ end
151
+
152
+ rescue SystemExit, Interrupt
153
+ ๐Ÿšฝ
154
+ exit!
155
+ end
156
+
157
+ end
158
+
159
+ end
160
+
161
+ end
162
+
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.2
4
+ version: 0.0.7
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-14 00:00:00.000000000 Z
11
+ date: 2021-02-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Allows a regular person to maintain a named list of secrets that's encrypted
14
14
  at rest
@@ -16,10 +16,13 @@ email: mwk@mikekeen.com
16
16
  executables:
17
17
  - uhide
18
18
  extensions: []
19
- extra_rdoc_files: []
19
+ extra_rdoc_files:
20
+ - README.md
20
21
  files:
22
+ - README.md
21
23
  - bin/uhide
22
24
  - lib/uhide.rb
25
+ - lib/uhide/main.rb
23
26
  homepage: https://github.com/mkeen/uhide
24
27
  licenses:
25
28
  - ISC (BSD2/MIT)