uhide 0.0.22 โ†’ 0.0.27

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/uhide +0 -1
  3. data/lib/uhide/main.rb +59 -62
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 834c424420ad584ea0272db71d512f553198f070a24d3daf629be266fa436a89
4
- data.tar.gz: 77a7ca4fb87eda9697bdcded4b251c043b8c05f4f77832a21f2603a5215de348
3
+ metadata.gz: 7549fe073a8fe7084cda772418064c3ae4a6ee461ed3aa366cd1f2e36f35fbf9
4
+ data.tar.gz: 745e42dcf130591deb94f771e5a38ee00201c770d006b13e86ca68c05633d861
5
5
  SHA512:
6
- metadata.gz: 99e1c4fa47bbdd973f35a60c93fbf9f75c75df0ec049113597b88aed1dd6e4e9adef5ddccd1fcc5ba53f79eec04d5becc4405752ac35d36160b3045c814b0dd8
7
- data.tar.gz: cfbda7cc184028979a9e979b00ca14e629871ae3ed89aba7220c46c0a06e42a5660d7f4a0877caa72bfba8cf78061646c84f71948de3622469dda7ebddccae54
6
+ metadata.gz: 91e97dea996846aaa2b82a6166aae57504615119ad89250187c00c6d87e3abe1ac9f8bdcb66c2b9e45f48e75903c99a65377ec05978eb7b2d88212a7dd7c886d
7
+ data.tar.gz: ca79538b4400dfcc213f099ce0c72f1404c7751488f726a0f5e4b00c7d8b1ab04d00cf2f2095feadbc05c6719fe7650f4522587b30385e28d6bc5cb41ed3a4de
data/bin/uhide CHANGED
@@ -20,7 +20,6 @@ Get Started:
20
20
  Commands and Optional Arguments:
21
21
  - get [key-name]
22
22
  - set [key-name] [key-value]
23
-
24
23
  HELP
25
24
  exit!
26
25
  end
data/lib/uhide/main.rb CHANGED
@@ -1,96 +1,58 @@
1
+ INVALID_๐Ÿ”‘ = 'invalid key'.colorize(:magenta)
2
+ UNSUPPORTED_๐Ÿ‘พ = 'unsupported'.colorize(:magenta) + ' ๐Ÿ‘พ'
3
+
1
4
  $โ˜” = " โ˜” > "
2
5
  $๐Ÿ”‘ = " ๐Ÿ”‘ > "
3
6
  $๐Ÿง‚ = -> { ๐Ÿ—ƒ๏ธ '๐Ÿง‚', SecureRandom.random_bytes }
4
7
  $๐Ÿ“ = -> { ๐Ÿ—ƒ๏ธ '๐Ÿ“', ActiveSupport::MessageEncryptor.key_len }
5
- INVALID_KEY = 'invalid key'.colorize(:red)
6
- UNSUPPORTED_๐Ÿ‘พ = 'unsupported'.colorize(:red) + ' ๐Ÿ‘พ'
7
- $cache = {}
8
-
9
- def password?
10
- ๐Ÿงผ STDIN.noecho(&:gets)
11
- end
8
+ $๐Ÿ—„๏ธ = {}
12
9
 
13
10
  def ๐Ÿšฝ
14
11
  print "\r"
15
12
  $stdout.flush
16
13
  end
17
14
 
15
+ def ๐Ÿงผ ๐Ÿ—‘๏ธ
16
+ ๐Ÿ—‘๏ธ.chomp
17
+ end
18
+
18
19
  def โ“ ๐Ÿ”‘, simple: true
19
20
  print ๐Ÿ”‘
20
- password = password?
21
- $password = password if simple
21
+ โœ๏ธ = ๐Ÿงผ STDIN.noecho(&:gets)
22
+ $โœ๏ธ = โœ๏ธ if simple
22
23
  ๐Ÿšฝ
23
- return password
24
- end
25
-
26
- def ๐Ÿงผ ๐Ÿ—‘๏ธ
27
- ๐Ÿ—‘๏ธ.chomp
24
+ return โœ๏ธ
28
25
  end
29
26
 
30
27
  def ๐Ÿ”“ ๐Ÿท๏ธ: nil
31
28
  if ๐Ÿท๏ธ.nil?
32
- puts $cache['ddllv']
29
+ puts $๐Ÿ—„๏ธ['ddllv']
33
30
  else
34
- puts $cache['ddllv'][๐Ÿท๏ธ]
31
+ puts $๐Ÿ—„๏ธ['ddllv'][๐Ÿท๏ธ]
35
32
  end
36
33
 
37
34
  ๐Ÿ“• = File.read './๐Ÿง‚'
38
35
  if ๐Ÿ“•.empty?
39
36
  ๐Ÿ”€ = SecureRandom.random_bytes $๐Ÿ“.call
40
37
  File.write './๐Ÿง‚', Marshal.dump(๐Ÿ”€)
41
- return $cache['๐Ÿง‚'] = ๐Ÿ”€
38
+ return $๐Ÿ—„๏ธ['๐Ÿง‚'] = ๐Ÿ”€
42
39
  else
43
- return $cache['๐Ÿง‚'] = Marshal.load(File.read './๐Ÿง‚')
40
+ return $๐Ÿ—„๏ธ['๐Ÿง‚'] = Marshal.load(File.read './๐Ÿง‚')
44
41
  end
45
42
 
46
43
  end
47
44
 
48
45
  def ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
49
- $cache['ddllv'][๐Ÿท๏ธ] = ๐Ÿ’Ž
46
+ $๐Ÿ—„๏ธ['ddllv'][๐Ÿท๏ธ] = ๐Ÿ’Ž
50
47
  ๐Ÿ’พ
51
48
  end
52
49
 
53
- def ๐Ÿค– ๐Ÿ—ฃ๏ธ
54
- ๐Ÿ‘พ, ๐Ÿท๏ธ, ๐Ÿ’Ž = ๐Ÿ—ฃ๏ธ.split
55
-
56
- if ๐Ÿ‘พ.nil?
57
- return
58
- end
59
-
60
- case ๐Ÿ‘พ.to_sym
61
- when :get
62
- if ๐Ÿท๏ธ
63
- ๐Ÿ”“ ๐Ÿท๏ธ: ๐Ÿท๏ธ
64
- else
65
- ๐Ÿ”“
66
- end
67
-
68
- when :set
69
- ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
70
-
71
- when :exit
72
- exit!
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
- else
83
- puts UNSUPPORTED_๐Ÿ‘พ
84
- end
85
-
86
- end
87
-
88
50
  def ๐Ÿ’พ
89
51
  โš›๏ธ = ActiveSupport::MessageEncryptor.new(
90
- ActiveSupport::KeyGenerator.new($password).generate_key($๐Ÿง‚.call, $๐Ÿ“.call)
52
+ ActiveSupport::KeyGenerator.new($โœ๏ธ).generate_key($๐Ÿง‚.call, $๐Ÿ“.call)
91
53
  )
92
54
 
93
- was_bootstrapped = !(not $cache['ddllv'])
55
+ was_bootstrapped = !(not $๐Ÿ—„๏ธ['ddllv'])
94
56
  ๐Ÿ“– = ๐Ÿ—ƒ๏ธ 'ddllv', {}, โš›๏ธ: โš›๏ธ
95
57
  ๐Ÿ“€ 'ddllv', ๐Ÿ“–, โš›๏ธ: โš›๏ธ if was_bootstrapped
96
58
  end
@@ -107,15 +69,15 @@ def ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ“–, โš›๏ธ: false
107
69
  return ๐Ÿ“•
108
70
  end
109
71
 
110
- def ๐Ÿ—ƒ๏ธ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: false
111
- if $cache[๐Ÿ—‚๏ธ]
112
- return $cache[๐Ÿ—‚๏ธ]
72
+ def ๐Ÿ—ƒ๏ธ ๐Ÿ—‚๏ธ, ๐Ÿ’Ž, โš›๏ธ: false
73
+ if $๐Ÿ—„๏ธ[๐Ÿ—‚๏ธ]
74
+ return $๐Ÿ—„๏ธ[๐Ÿ—‚๏ธ]
113
75
  end
114
76
 
115
77
  begin
116
78
  ๐Ÿ“• = File.read "./#{๐Ÿ—‚๏ธ}"
117
79
  rescue Errno::ENOENT
118
- ๐Ÿ“• = ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: โš›๏ธ
80
+ ๐Ÿ“• = ๐Ÿ“€ ๐Ÿ—‚๏ธ, ๐Ÿ’Ž, โš›๏ธ: โš›๏ธ
119
81
  end
120
82
 
121
83
  if not ๐Ÿ“•.empty?
@@ -125,7 +87,7 @@ def ๐Ÿ—ƒ๏ธ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: false
125
87
  begin
126
88
  ๐Ÿ“– = โš›๏ธ.decrypt_and_verify ๐Ÿ“•
127
89
  rescue ActiveSupport::MessageVerifier::InvalidSignature
128
- puts INVALID_KEY
90
+ puts INVALID_๐Ÿ”‘
129
91
  exit!
130
92
  end
131
93
 
@@ -135,7 +97,42 @@ def ๐Ÿ—ƒ๏ธ ๐Ÿ—‚๏ธ, ๐Ÿ”€, โš›๏ธ: false
135
97
 
136
98
  end
137
99
 
138
- return $cache[๐Ÿ—‚๏ธ] = ๐Ÿ“–
100
+ return $๐Ÿ—„๏ธ[๐Ÿ—‚๏ธ] = ๐Ÿ“–
101
+ end
102
+
103
+ def ๐Ÿค– ๐Ÿ—ฃ๏ธ
104
+ ๐Ÿ‘พ, ๐Ÿท๏ธ, ๐Ÿ’Ž = ๐Ÿ—ฃ๏ธ.split
105
+
106
+ if ๐Ÿ‘พ.nil?
107
+ return
108
+ end
109
+
110
+ case ๐Ÿ‘พ.to_sym
111
+ when :get
112
+ if ๐Ÿท๏ธ
113
+ ๐Ÿ”“ ๐Ÿท๏ธ: ๐Ÿท๏ธ
114
+ else
115
+ ๐Ÿ”“
116
+ end
117
+
118
+ when :set
119
+ ๐Ÿ”’ ๐Ÿท๏ธ, ๐Ÿ’Ž
120
+
121
+ when :exit
122
+ exit!
123
+
124
+ when :reset
125
+ if โ“($๐Ÿ”‘, simple: false) == $โœ๏ธ
126
+ ['ddllv', '๐Ÿง‚', '๐Ÿ“'].each_entry { |item| File.delete "./#{item}" }
127
+ exit!
128
+ else
129
+ puts INVALID_๐Ÿ”‘
130
+ end
131
+
132
+ else
133
+ puts UNSUPPORTED_๐Ÿ‘พ
134
+ end
135
+
139
136
  end
140
137
 
141
138
  class Uhide::Main
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uhide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Keen