rubeepass 0.1.2 → 0.2.0

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/rpass +8 -15
  3. data/lib/rubeepass.rb +37 -17
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abe38f261905a7621be6738e64e28b20898e092c
4
- data.tar.gz: 4da29b094e19fcfbaab0f9e6b553a263615c06e1
3
+ metadata.gz: 46705ef9bef7799846f434283b6e7856dea540d4
4
+ data.tar.gz: fc21cc8636d4e1a871fd7eaff58c517ac20b563f
5
5
  SHA512:
6
- metadata.gz: 500bf5533738d8db41ad428289d93948bea52141ec0e1fc1bafb3896d7cc3a7523ad13f60343d7c2e97e2a037240665e445cbbe999ec0ff23f9c68c32691e9bb
7
- data.tar.gz: 1cff2527401f526cec0bd5d8dc36b99b46bdc361d1d9e3f88ed27c085163f4fe01e507ce4ce3f22016d2ca84e921802453e792884231675d658e543bcbe82e66
6
+ metadata.gz: c0b2b619726ac9f62455e9740a544ffb86301d6215ccd9c5d2227f2e69711edc25ad427231c8783e8a49465ddd2e733a4896ecc175814c7ce7a80acb12eff698
7
+ data.tar.gz: 7e96d550b350b80d3822db5d1713f07ed77be9dc841639f2eaaaca351ff9ecb7b776ed020f9fcf0df69e7983be969d56760a9eebac684578915101c72d7b8a0c
data/bin/rpass CHANGED
@@ -204,26 +204,19 @@ password = options["password"] if (options["password"])
204
204
  password = get_password if (options["password"].nil?)
205
205
  keyfile = options["keyfile"]
206
206
 
207
- keepass = nil
207
+ keepass = RubeePass.new(kdbx, password, keyfile)
208
+
209
+ if (options["export_file"])
210
+ keepass.export(options["export_file"], options["export_format"])
211
+ exit RPassExit::GOOD
212
+ end
213
+
208
214
  begin
209
- keepass = RubeePass.new(kdbx, password, keyfile).open
215
+ keepass.open
210
216
  rescue RubeePass::Error => e
211
217
  puts e.message
212
218
  exit RPassExit::KDBX_NOT_OPENED
213
219
  end
214
- exit RPassExit::KDBX_NOT_OPENED if (keepass.nil?)
215
-
216
- if (options["export_file"])
217
- File.open(options["export_file"], "w") do |f|
218
- case options["export_format"]
219
- when "gzip"
220
- f.write(keepass.gzip)
221
- when "xml"
222
- f.write(keepass.xml)
223
- end
224
- end
225
- exit RPassExit::GOOD
226
- end
227
220
 
228
221
  djinni = Djinni.new
229
222
  djinni.load_wishes("#{File.dirname(__FILE__)}/../lib/builtins")
data/lib/rubeepass.rb CHANGED
@@ -138,6 +138,19 @@ class RubeePass
138
138
  end
139
139
  private :derive_aes_key
140
140
 
141
+ def export(export_file, format)
142
+ start_opening
143
+
144
+ File.open(export_file, "w") do |f|
145
+ case format
146
+ when "gzip"
147
+ f.write(@gzip)
148
+ when "xml"
149
+ f.write(@xml)
150
+ end
151
+ end
152
+ end
153
+
141
154
  def extract_xml
142
155
  @xml = Zlib::GzipReader.new(StringIO.new(@gzip)).read
143
156
  end
@@ -165,16 +178,9 @@ class RubeePass
165
178
  private :handle_protected
166
179
 
167
180
  def initialize(kdbx, password, keyfile = nil)
168
- @aes_iv = nil
169
- @aes_key = nil
170
- @db = nil
171
- @gzip = nil
172
- @header = nil
173
181
  @kdbx = kdbx
174
- @key = nil
175
182
  @keyfile = keyfile
176
183
  @password = password
177
- @xml = nil
178
184
  end
179
185
 
180
186
  def join_key_and_keyfile
@@ -241,15 +247,7 @@ class RubeePass
241
247
  end
242
248
 
243
249
  def open
244
- file = File.open(@kdbx)
245
-
246
- read_magic_and_version(file)
247
- read_header(file)
248
- join_key_and_keyfile
249
- derive_aes_key
250
- read_gzip(file)
251
-
252
- file.close
250
+ start_opening
253
251
 
254
252
  @protected_decryptor = ProtectedDecryptor.new(
255
253
  Digest::SHA256.digest(
@@ -258,7 +256,6 @@ class RubeePass
258
256
  ["E830094B97205D2A"].pack("H*")
259
257
  )
260
258
 
261
- extract_xml
262
259
  parse_xml
263
260
 
264
261
  return self
@@ -487,6 +484,29 @@ class RubeePass
487
484
  end
488
485
  private :read_magic_and_version
489
486
 
487
+ def start_opening
488
+ @aes_iv = nil
489
+ @aes_key = nil
490
+ @db = nil
491
+ @gzip = nil
492
+ @header = nil
493
+ @key = nil
494
+ @xml = nil
495
+
496
+ file = File.open(@kdbx)
497
+
498
+ read_magic_and_version(file)
499
+ read_header(file)
500
+ join_key_and_keyfile
501
+ derive_aes_key
502
+ read_gzip(file)
503
+
504
+ file.close
505
+
506
+ extract_xml
507
+ end
508
+ private :start_opening
509
+
490
510
  def to_s
491
511
  return @db.to_s
492
512
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubeepass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Whittaker