uhide 0.0.2 โ 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -0
- data/bin/uhide +2 -3
- data/lib/uhide.rb +2 -150
- data/lib/uhide/main.rb +162 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a8fd79cc30cb4eff3b0da4798c5d9c72557148d5bd004b74b359acd39ee08ac
|
4
|
+
data.tar.gz: f4f931d8f2c0ff7ac55fe3d90ec53a0e6840d6e08dcf1678758a0bdaa00e353e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/lib/uhide.rb
CHANGED
@@ -1,153 +1,5 @@
|
|
1
|
-
|
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
|
-
|
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.
|
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-
|
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)
|