fernet-cli 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +3 -0
- data/Rakefile +2 -0
- data/bin/fernet-decrypt +60 -0
- data/bin/fernet-encrypt +50 -0
- data/fernet-cli.gemspec +21 -0
- data/lib/fernet/cli/version.rb +5 -0
- data/version +1 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5bc1ba7e595b73d8bf6e87bbe0b6cfa458da9822
|
4
|
+
data.tar.gz: eeb6d5e25640ddcbe6a393a13afac0cc7101ced4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f9ab85bdca745f3a57119303e2341287eb534bf058e37820a402412b3a831babb846c9a4be18d9d9c135c79acadcf7dada2f737d660191ef5102b411f34cd9e
|
7
|
+
data.tar.gz: 53c3d8341c19c1ffb707ef6f7c27e915ad3e9223452be71257f523bc7330f92f92d5ca2b9a6cfbc03ce724d4f1deefc2254a65f79a2dee8c8b2329937ad2e097
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/fernet-decrypt
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fernet'
|
4
|
+
require 'optparse'
|
5
|
+
require 'highline/import'
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: fernet-decrypt [-p | -k <keyfile>] -i <ciphertext> -o <plaintext>"
|
10
|
+
|
11
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
12
|
+
options[:verbose] = v
|
13
|
+
end
|
14
|
+
opts.on("-p", "--prompt", "Prompt for keys") do |prompt|
|
15
|
+
options[:prompt] = prompt
|
16
|
+
end
|
17
|
+
opts.on("-k", "--keyfile KEYFILE") do |keyfile|
|
18
|
+
options[:keyfile] = keyfile
|
19
|
+
end
|
20
|
+
opts.on("-i", "--infile CIPHERFILE") do |cipherfile|
|
21
|
+
options[:cipherfile] = cipherfile
|
22
|
+
end
|
23
|
+
opts.on("-o", "--outfile PLAINFILE") do |plainfile|
|
24
|
+
options[:plainfile] = plainfile
|
25
|
+
end
|
26
|
+
opts.on("--enforce-ttl") do |ttl|
|
27
|
+
options[:ttl] = true
|
28
|
+
end
|
29
|
+
end.parse!
|
30
|
+
|
31
|
+
if ENV["FERNET_CLI_KEY"].nil?
|
32
|
+
if options[:prompt]
|
33
|
+
KEY = ask("Enter Key: ") {|q| q.echo = false}
|
34
|
+
elsif options[:keyfile]
|
35
|
+
KEY = File.read(options[:keyfile]).chomp
|
36
|
+
end
|
37
|
+
else
|
38
|
+
KEY=ENV["FERNET_CLI_KEY"]
|
39
|
+
end
|
40
|
+
|
41
|
+
if KEY.nil?
|
42
|
+
puts "i have no key"
|
43
|
+
exit(1)
|
44
|
+
end
|
45
|
+
|
46
|
+
if options[:cipherfile].nil? or (! File.readable?(options[:cipherfile]))
|
47
|
+
puts "can't read ciphertext file"
|
48
|
+
exit(1)
|
49
|
+
end
|
50
|
+
|
51
|
+
plaintext = Fernet.verifier(KEY.chomp, File.read(options[:cipherfile]),
|
52
|
+
enforce_ttl: options[:ttl])
|
53
|
+
if ! plaintext.valid?
|
54
|
+
puts "ciphertext corrupt"
|
55
|
+
exit(1)
|
56
|
+
end
|
57
|
+
|
58
|
+
File.open(options[:plainfile], "w+") do |f|
|
59
|
+
f.write(plaintext.message)
|
60
|
+
end
|
data/bin/fernet-encrypt
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fernet'
|
4
|
+
require 'optparse'
|
5
|
+
require 'highline/import'
|
6
|
+
|
7
|
+
options = {}
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: fernet-encrypt [-p | -k <keyfile>] -i <plaintext> -o <ciphertext>"
|
10
|
+
|
11
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
12
|
+
options[:verbose] = v
|
13
|
+
end
|
14
|
+
opts.on("-p", "--prompt", "Prompt for keys") do |prompt|
|
15
|
+
options[:prompt] = prompt
|
16
|
+
end
|
17
|
+
opts.on("-k", "--keyfile KEYFILE") do |keyfile|
|
18
|
+
options[:keyfile] = keyfile
|
19
|
+
end
|
20
|
+
opts.on("-i", "--infile PLAINFILE") do |plainfile|
|
21
|
+
options[:plainfile] = plainfile
|
22
|
+
end
|
23
|
+
opts.on("-o", "--outfile CIPHERFILE") do |cipherfile|
|
24
|
+
options[:cipherfile] = cipherfile
|
25
|
+
end
|
26
|
+
end.parse!
|
27
|
+
|
28
|
+
if ENV["FERNET_CLI_KEY"].nil?
|
29
|
+
if options[:prompt]
|
30
|
+
KEY = ask("Enter Key: ") {|q| q.echo = false}
|
31
|
+
elsif options[:keyfile]
|
32
|
+
KEY = File.read(options[:keyfile]).chomp
|
33
|
+
end
|
34
|
+
else
|
35
|
+
KEY=ENV["FERNET_CLI_KEY"]
|
36
|
+
end
|
37
|
+
|
38
|
+
if KEY.nil?
|
39
|
+
puts "i have no key"
|
40
|
+
exit(1)
|
41
|
+
end
|
42
|
+
|
43
|
+
if options[:plainfile].nil? or (! File.readable?(options[:plainfile]))
|
44
|
+
puts "can't read plaintext file"
|
45
|
+
exit(1)
|
46
|
+
end
|
47
|
+
|
48
|
+
File.open(options[:cipherfile], "w+") do |f|
|
49
|
+
f.write(Fernet.generate(KEY.chomp, File.read(options[:plainfile])))
|
50
|
+
end
|
data/fernet-cli.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/fernet/cli/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Tom Maher"]
|
6
|
+
gem.email = ["tmaher@pw0n.me"]
|
7
|
+
gem.description = "CLI for Fernet"
|
8
|
+
gem.summary = "Work with Fernet-encrypted files in the command line"
|
9
|
+
gem.homepage = "https://github.com/tmaher/fernet-cli"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "fernet-cli"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Fernet::CLI::VERSION
|
17
|
+
gem.license = "Apache-2.0"
|
18
|
+
|
19
|
+
gem.add_runtime_dependency "fernet", "~> 2.0"
|
20
|
+
gem.add_development_dependency "rspec", "~> 2.14"
|
21
|
+
end
|
data/version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fernet-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Maher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fernet
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.14'
|
41
|
+
description: CLI for Fernet
|
42
|
+
email:
|
43
|
+
- tmaher@pw0n.me
|
44
|
+
executables:
|
45
|
+
- fernet-decrypt
|
46
|
+
- fernet-encrypt
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- Rakefile
|
53
|
+
- bin/fernet-decrypt
|
54
|
+
- bin/fernet-encrypt
|
55
|
+
- fernet-cli.gemspec
|
56
|
+
- lib/fernet/cli/version.rb
|
57
|
+
- version
|
58
|
+
homepage: https://github.com/tmaher/fernet-cli
|
59
|
+
licenses:
|
60
|
+
- Apache-2.0
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.0
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Work with Fernet-encrypted files in the command line
|
82
|
+
test_files: []
|