rgpg 0.0.0 → 0.1.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.
Potentially problematic release.
This version of rgpg might be problematic. Click here for more details.
- data/bin/rgpg +47 -0
- metadata +4 -2
data/bin/rgpg
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'tempfile'
|
5
|
+
require 'gpg_helper'
|
6
|
+
|
7
|
+
THIS_PATH = Pathname.new(__FILE__).realpath
|
8
|
+
THIS_DIR = THIS_PATH.dirname
|
9
|
+
THIS_BASE_NAME = File.basename($0, File.extname($0))
|
10
|
+
|
11
|
+
GENERATE_KEY_PAIR_USAGE = '--generate-key-pair <key-base-name> <recipient> <real-name>'
|
12
|
+
ENCRYPT_USAGE = '--encrypt <public-key-file-name> <input-file-name> <output-file-name>'
|
13
|
+
DECRYPT_USAGE = '--decrypt <public-key-file-name> <private-key-file-name> <input-file-name> <output-file-name>'
|
14
|
+
|
15
|
+
if ARGV[0] == '--generate-key-pair'
|
16
|
+
raise RuntimeError.new(GENERATE_KEY_PAIR_USAGE) unless ARGV.size == 4
|
17
|
+
key_base_name = ARGV[1]
|
18
|
+
recipient = ARGV[2]
|
19
|
+
real_name = ARGV[3]
|
20
|
+
GpgHelper.generate_key_pair(key_base_name, recipient, real_name)
|
21
|
+
exit 0
|
22
|
+
elsif ARGV[0] == '--encrypt'
|
23
|
+
raise RuntimeError.new(ENCRYPT_USAGE) unless ARGV.size == 4
|
24
|
+
public_key_file_name = ARGV[1]
|
25
|
+
input_file_name = ARGV[2]
|
26
|
+
output_file_name = ARGV[3]
|
27
|
+
GpgHelper.encrypt_file(public_key_file_name, input_file_name, output_file_name)
|
28
|
+
exit 0
|
29
|
+
elsif ARGV[0] == '--decrypt'
|
30
|
+
raise RuntimeError.new(DECRYPT_USAGE) unless ARGV.size == 5
|
31
|
+
public_key_file_name = ARGV[1]
|
32
|
+
private_key_file_name = ARGV[2]
|
33
|
+
input_file_name = ARGV[3]
|
34
|
+
output_file_name = ARGV[4]
|
35
|
+
GpgHelper.decrypt_file(public_key_file_name, private_key_file_name, input_file_name, output_file_name)
|
36
|
+
exit 0
|
37
|
+
else
|
38
|
+
$stderr.puts "Unsupported command \"#{ARGV[0]}\"" unless ARGV[0].nil? || ARGV[0].size == 0
|
39
|
+
$stderr.puts 'Usage:'
|
40
|
+
$stderr.puts " #{THIS_BASE_NAME} <command> <arg0> ... <argN-1>"
|
41
|
+
$stderr.puts 'Available commands:'
|
42
|
+
$stderr.puts " #{GENERATE_KEY_PAIR_USAGE}"
|
43
|
+
$stderr.puts " #{ENCRYPT_USAGE}"
|
44
|
+
$stderr.puts " #{DECRYPT_USAGE}"
|
45
|
+
exit 1
|
46
|
+
end
|
47
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgpg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,11 +13,13 @@ date: 2013-07-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
14
14
|
description: Simple Ruby wrapper around "gpg" command for file encryption
|
15
15
|
email: rcook@rcook.org
|
16
|
-
executables:
|
16
|
+
executables:
|
17
|
+
- rgpg
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
20
21
|
- lib/gpg_helper.rb
|
22
|
+
- bin/rgpg
|
21
23
|
homepage: https://github.com/rcook/rgpg/
|
22
24
|
licenses: []
|
23
25
|
post_install_message:
|