dgen 0.3.1 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b4e97d160a790de39dfc8ffe12e5e43dd71f9e0
4
- data.tar.gz: 52d7dfb9b70f0db972e19da29d593e202a75721d
3
+ metadata.gz: 703010a0616cbf836188f4b6c13561cafb8c825c
4
+ data.tar.gz: 21fb56a831f02280419cb6a1957d35310dfbf45f
5
5
  SHA512:
6
- metadata.gz: 1632f406a509240eaa56c32c41ebf835fde80b366df78945a24f49b9d965741031886a097616ee3a49ae022c286394e7d1af0436b08da406e4d1592c24081f55
7
- data.tar.gz: 70ad86ca87eb92701fb4787cf54043d08cdd74eb701e1839cebcbc768b02a3f6e4cc149fff6b0edcc4c72908081d7345810b397ddb20cee62c185dacf9790425
6
+ metadata.gz: 8cc7055162419bc1a12676c6c591b509e7d25cc4412dd193cebe6ea211931b33e0b4d72151785570117ce18f6a3360d997e57a0d22f0f45eb2c949c954f8951f
7
+ data.tar.gz: 9fc9e38604af5795f64943c5500596f9ee82a5cb60492c165a36f4c8a4ba4a7844bb083fe203e98db5f9a2bc499af33d0f0a8293f8e8e0b8ff168f64b089dabd
data/lib/dgen/base.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  ##
2
- # Base Script
3
- #
4
- # This script handles the behavior of the program based on the options
5
- # provided by the user.
2
+ # dgen
6
3
  #
7
4
  # Copyright 2015 Richard Davis GPL v3
8
5
  require 'optparse'
@@ -10,7 +7,7 @@ require 'dgen/passgen.rb'
10
7
  require 'dgen/outputfile.rb'
11
8
 
12
9
  trap('INT') do
13
- puts 'Terminating...'
10
+ puts "\nTerminating..."
14
11
  exit
15
12
  end
16
13
 
@@ -71,7 +68,7 @@ if options[:single]
71
68
  end
72
69
  elsif options[:batch]
73
70
  batch_pass = PassGen.batch(n_words, p_length)
74
- puts 'Save the passphrases in an encrypted file? (Y/N) => '
71
+ print 'Save the passphrases in an encrypted file? (Y/N) => '
75
72
  save = gets.chomp
76
73
  exit unless save.upcase == 'Y'
77
74
  begin
@@ -12,21 +12,20 @@ require 'crypt/blowfish'
12
12
  #
13
13
  module OutputFile
14
14
  ##
15
- # Encrypts a given passphrase.
15
+ # Encrypts a plaintext file using blowfish encryption.
16
16
  #
17
- def self.encrypt(phrase, key)
18
- blowfish = Crypt::Blowfish.new(key)
19
- e_phrase = blowfish.encrypt_string(phrase)
20
- e_phrase
17
+ def self.encrypt(file, key)
18
+ bf = Crypt::Blowfish.new(key)
19
+ bf.encrypt_file("plain_#{file}", "#{file}")
20
+ File.delete("plain_#{file}")
21
21
  end
22
22
 
23
23
  ##
24
- # Decrypts a given passphrase.
24
+ # Decrypts a blowfish encrypted file.
25
25
  #
26
- def self.decrypt(e_phrase, key)
27
- blowfish = Crypt::Blowfish.new(key)
28
- phrase = blowfish.decrypt_string(e_phrase)
29
- phrase
26
+ def self.decrypt(file, key)
27
+ bf = Crypt::Blowfish.new(key)
28
+ bf.decrypt_file("#{file}", "decrypted_#{file}")
30
29
  end
31
30
 
32
31
  ##
@@ -35,12 +34,12 @@ module OutputFile
35
34
  def self.save_pass(phrase)
36
35
  print 'Enter name for output file => '
37
36
  o_file = gets.chomp
38
- f = File.open("#{o_file}", 'w+')
39
37
  print 'Enter a key for encryption => '
40
38
  key = gets.chomp
41
- e_phrase = encrypt(phrase, key)
42
- f.puts e_phrase
39
+ f = File.open("plain_#{o_file}", 'w+')
40
+ f.puts phrase
43
41
  f.close
42
+ encrypt(o_file, key)
44
43
  end
45
44
 
46
45
  ##
@@ -49,14 +48,14 @@ module OutputFile
49
48
  def self.save_batch(phrase)
50
49
  print 'Enter name for output file => '
51
50
  o_file = gets.chomp
52
- f = File.open("#{o_file}", 'w+')
53
51
  print 'Enter a key for encryption => '
54
52
  key = gets.chomp
53
+ f = File.open("plain_#{o_file}", 'w+')
55
54
  phrase.each do |p|
56
- e_phrase = encrypt(p, key)
57
- f.puts e_phrase
55
+ f.write p + "\n"
58
56
  end
59
57
  f.close
58
+ encrypt(o_file, key)
60
59
  end
61
60
 
62
61
  ##
@@ -65,10 +64,10 @@ module OutputFile
65
64
  def self.open_ofile(file)
66
65
  print 'Enter a key for decryption => '
67
66
  key = gets.chomp
68
- File.foreach(file) do |l|
69
- e_phrase = l.chomp
70
- phrase = decrypt(e_phrase, key)
71
- puts "Decrypted passphrase: '#{phrase}'"
67
+ decrypt(file, key)
68
+ File.foreach("decrypted_#{file}") do |l|
69
+ puts "Decrypted passphrase: '#{l.chomp}'"
72
70
  end
71
+ File.delete("decrypted_#{file}")
73
72
  end
74
73
  end
data/lib/dgen/passgen.rb CHANGED
@@ -68,8 +68,7 @@ module PassGen
68
68
  def self.single(n_words, p_length)
69
69
  f = open_wordlist
70
70
  phrase = make_phrase(n_words, p_length, f)
71
- puts "Passphrase with spaces: '#{phrase}'"
72
- puts "Passphrase without spaces: '#{phrase.delete(' ')}'"
71
+ puts "Passphrase: '#{phrase}'"
73
72
  f.close
74
73
  phrase
75
74
  end
@@ -84,8 +83,7 @@ module PassGen
84
83
  num_pass = gets.chomp.to_i
85
84
  num_pass.times do |i|
86
85
  phrase.push(make_phrase(n_words, p_length, f))
87
- puts "Passphrase with spaces: '#{phrase[i]}'"
88
- puts "Passphrase without spaces: '#{phrase[i].delete(' ')}'"
86
+ puts "Passphrase: '#{phrase[i]}'"
89
87
  end
90
88
  f.close
91
89
  phrase
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-25 00:00:00.000000000 Z
11
+ date: 2015-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: crypt