helpema 3.0.210706 → 3.1.210909
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -7
- data/lib/helpema/gpg.rb +86 -0
- data/lib/helpema/helpema.rb +10 -4
- data/lib/helpema/ssss.rb +12 -3
- data/lib/helpema.rb +3 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06db87416d69a4ed736c20927d8f9d3c379d7654cbd3e85f57e6e44a5571098e
|
4
|
+
data.tar.gz: e0f8202e576a5ba7d7fb30ec1b045bc8da3bf1c696bf98874b30c032820e45a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e59e80e64f0c88ac0a0948ff773b9238f7334939231d70c70aec105217962cc4e3e68276b29013cb4e22eec57e392031b2f927c690d29d35999ca236860b1ee
|
7
|
+
data.tar.gz: aaddb40d73e6d372d50ff61244232dbc998076806dcc3903fefd1c46647e3f739bfd9b0b0d6d29ab4b56c8bfb0411d2314bee2505ceae11c90ffeb717b2cf781
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Helpema
|
2
2
|
|
3
|
-
* [VERSION 3.
|
3
|
+
* [VERSION 3.1.210909](https://github.com/carlosjhr64/helpema/releases)
|
4
4
|
* [github](https://github.com/carlosjhr64/helpema)
|
5
5
|
* [rubygems](https://rubygems.org/gems/helpema)
|
6
6
|
|
@@ -12,7 +12,7 @@ Featured method: `requires "good ~>3.0", "bad ~>2.7", "ugly ~>1.8"`
|
|
12
12
|
|
13
13
|
## INSTALL:
|
14
14
|
|
15
|
-
```
|
15
|
+
```console
|
16
16
|
$ gem install helpema
|
17
17
|
```
|
18
18
|
|
@@ -30,7 +30,7 @@ using Helpema
|
|
30
30
|
# that annoyingly keep falling out of maintainance... right?
|
31
31
|
requires'
|
32
32
|
ruby ~>3.0
|
33
|
-
helpema ~>3.
|
33
|
+
helpema ~>3.1
|
34
34
|
base_convert ~>4.0
|
35
35
|
entropia ~>0.1'
|
36
36
|
#=> ["base_convert", "entropia"]
|
@@ -61,7 +61,12 @@ to_arg :geo=, '10x20' #=> "--geo=10x20"
|
|
61
61
|
to_arg :arg0, 'Hello World' #=> "Hello World"
|
62
62
|
|
63
63
|
### Hash#to_args ###
|
64
|
-
{q:
|
64
|
+
{ q: true,
|
65
|
+
quiet: true,
|
66
|
+
verbose: false,
|
67
|
+
f: '/path-to/file',
|
68
|
+
:geo= => '10x20',
|
69
|
+
arg0: 'Hello World' }.to_args
|
65
70
|
#=> ["-q", "--quiet", "-f", "/path-to/file", "--geo=10x20", "Hello World"]
|
66
71
|
|
67
72
|
### Array#classify ###
|
@@ -76,7 +81,8 @@ SSSS.split(secret: "Top Secret!", threshold: 2, shares: 3)
|
|
76
81
|
|
77
82
|
#### SSSS.combine ###
|
78
83
|
# Pregenerated splits combine to reproduce the secret.
|
79
|
-
SSSS.combine(secrets: ["3-055562917c41e68c6ab2c8", "1-27bf3cbfe8d2c25c7e8928"],
|
84
|
+
SSSS.combine(secrets: ["3-055562917c41e68c6ab2c8", "1-27bf3cbfe8d2c25c7e8928"],
|
85
|
+
threshold: 2)
|
80
86
|
#=> "Top Secret!"
|
81
87
|
|
82
88
|
### YouTubeDL.json ###
|
@@ -95,7 +101,34 @@ string_or_nil = ZBar.screen
|
|
95
101
|
### ZBar.cam ###
|
96
102
|
# Reads qrcodes from camera.
|
97
103
|
# You may want to wrap this one in a Timeout block.
|
98
|
-
string = ZBar.cam
|
104
|
+
# string = ZBar.cam
|
105
|
+
|
106
|
+
### GPG Symmetric ###
|
107
|
+
## String to String
|
108
|
+
encrypted = GPG.encrypt(passphrase: '<Secret>', string: '<Plain Text>')
|
109
|
+
decrypted = GPG.decrypt(passphrase: '<Secret>', string: encrypted)
|
110
|
+
#=> "<Plain Text>"
|
111
|
+
## File to File
|
112
|
+
# Got a text file...
|
113
|
+
`md5sum tmp/text.txt` #~> ^d27b3111fdeb72f2862909c216214bc1
|
114
|
+
# gpg wont overwrite, so need to remove existing...
|
115
|
+
File.exist?(_='tmp/text.enc') and File.unlink(_)
|
116
|
+
File.exist?(_='tmp/text.dec') and File.unlink(_)
|
117
|
+
# Encrypt text file...
|
118
|
+
GPG.encrypt(passphrase: '<Secret>', input: 'tmp/text.txt', output: 'tmp/text.enc') #=> ""
|
119
|
+
# Decrypt encrypted file...
|
120
|
+
GPG.decrypt(passphrase: '<Secret>', input: 'tmp/text.enc', output: 'tmp/text.dec') #=> ""
|
121
|
+
# Decrypted file should match...
|
122
|
+
`md5sum tmp/text.dec` #~> ^d27b3111fdeb72f2862909c216214bc1
|
123
|
+
## IO to IO
|
124
|
+
require 'stringio'
|
125
|
+
pio = StringIO.new '<Plain>'
|
126
|
+
eio = StringIO.new ''
|
127
|
+
dio = StringIO.new ''
|
128
|
+
GPG.encrypt(passphrase: '<Secret>', ioin: pio, ioout: eio)
|
129
|
+
eio.rewind
|
130
|
+
GPG.decrypt(passphrase: '<Secret>', ioin: eio, ioout: dio)
|
131
|
+
dio.string #=> "<Plain>"
|
99
132
|
```
|
100
133
|
|
101
134
|
## TROUBLESHOOTING:
|
@@ -110,7 +143,7 @@ More documentation
|
|
110
143
|
|
111
144
|
(The MIT License)
|
112
145
|
|
113
|
-
Copyright (c) 2021
|
146
|
+
Copyright (c) 2021 CarlosJHR64
|
114
147
|
|
115
148
|
Permission is hereby granted, free of charge, to any person obtaining
|
116
149
|
a copy of this software and associated documentation files (the
|
data/lib/helpema/gpg.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
module Helpema
|
2
|
+
module GPG
|
3
|
+
extend Helpema
|
4
|
+
class << self; attr_accessor :version; end
|
5
|
+
GPG.version = '^gpg \\(GnuPG\\) 2\.[234]\.' # version as of this writing is 2.2.27
|
6
|
+
|
7
|
+
GPG.define_command(:cryptor,
|
8
|
+
cmd: 'gpg', version: GPG.version,
|
9
|
+
usage: {
|
10
|
+
quiet: true,
|
11
|
+
batch: true,
|
12
|
+
'passphrase-fd': 0,
|
13
|
+
output: nil,
|
14
|
+
symmetric: nil,
|
15
|
+
decrypt: nil,
|
16
|
+
arg0: nil,
|
17
|
+
},
|
18
|
+
synonyms: {
|
19
|
+
input: :arg0,
|
20
|
+
},
|
21
|
+
mode: 'w+',
|
22
|
+
exception: 'gpg failed'
|
23
|
+
) do |pipe, options, blk|
|
24
|
+
passphrase, string, ioin, ioout =
|
25
|
+
options.fetch_values(:passphrase, :string, :ioin, :ioout)
|
26
|
+
pipe.puts passphrase
|
27
|
+
Thread.new do
|
28
|
+
if string
|
29
|
+
pipe.write string
|
30
|
+
elsif ioin
|
31
|
+
while c = ioin.getbyte
|
32
|
+
pipe.putc c
|
33
|
+
end
|
34
|
+
end
|
35
|
+
pipe.close_write
|
36
|
+
end
|
37
|
+
if ioout
|
38
|
+
while c = pipe.getbyte
|
39
|
+
ioout.putc c
|
40
|
+
end
|
41
|
+
else
|
42
|
+
pipe.read
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def encrypt(passphrase:,
|
47
|
+
string:nil,
|
48
|
+
output:nil,
|
49
|
+
input:nil,
|
50
|
+
ioin:nil,
|
51
|
+
ioout:nil)
|
52
|
+
unless [string,input,ioin].count{_1} == 1
|
53
|
+
raise "Need only one of string, input, or ioin"
|
54
|
+
end
|
55
|
+
raise "Can't have both output and ioout" if output and ioout
|
56
|
+
GPG.cryptor(symmetric: true,
|
57
|
+
passphrase: passphrase,
|
58
|
+
string: string,
|
59
|
+
input: input,
|
60
|
+
output: output,
|
61
|
+
ioin: ioin,
|
62
|
+
ioout: ioout)
|
63
|
+
end
|
64
|
+
|
65
|
+
def decrypt(passphrase:,
|
66
|
+
string:nil,
|
67
|
+
output:nil,
|
68
|
+
input:nil,
|
69
|
+
ioin:nil,
|
70
|
+
ioout:nil)
|
71
|
+
unless [string,input,ioin].count{_1} == 1
|
72
|
+
raise "Need only one of string, input, or ioin"
|
73
|
+
end
|
74
|
+
raise "Can't have both output and ioout" if output and ioout
|
75
|
+
GPG.cryptor(decrypt: true,
|
76
|
+
passphrase: passphrase,
|
77
|
+
string: string,
|
78
|
+
input: input,
|
79
|
+
output: output,
|
80
|
+
ioin: ioin,
|
81
|
+
ioout: ioout)
|
82
|
+
end
|
83
|
+
|
84
|
+
extend self
|
85
|
+
end
|
86
|
+
end
|
data/lib/helpema/helpema.rb
CHANGED
@@ -15,7 +15,7 @@ module Helpema
|
|
15
15
|
# convert key,value tuples to final list of args
|
16
16
|
args.map!(&:to_arg)
|
17
17
|
# get rid of nil
|
18
|
-
args.
|
18
|
+
args.compact!
|
19
19
|
# ...and finally flatten!
|
20
20
|
args.flatten!
|
21
21
|
return args
|
@@ -58,7 +58,9 @@ module Helpema
|
|
58
58
|
args,ret = options.to_args(usage:usage,synonyms:synonyms),nil
|
59
59
|
$stderr.puts "#{cmd} #{args.join(' ')}" if $DEBUG
|
60
60
|
IO.popen([cmd, *args], mode, **popt) do |pipe|
|
61
|
-
ret =
|
61
|
+
ret = forward_pass ? forward_pass.call(pipe, options, blk) :
|
62
|
+
blk ? blk.call(pipe) :
|
63
|
+
pipe.read
|
62
64
|
end
|
63
65
|
(exception.nil? or $?.exitstatus==0)? ret : raise(exception)
|
64
66
|
end
|
@@ -93,10 +95,14 @@ module Helpema
|
|
93
95
|
unless reqs.empty?
|
94
96
|
case gemname
|
95
97
|
when 'helpema'
|
96
|
-
|
98
|
+
unless VERSION.satisfies?(*reqs)
|
99
|
+
raise "helpema #{VERSION} not #{reqs.join(', ')}"
|
100
|
+
end
|
97
101
|
next
|
98
102
|
when 'ruby'
|
99
|
-
|
103
|
+
unless RUBY_VERSION.satisfies?(*reqs)
|
104
|
+
raise "ruby #{RUBY_VERSION} not #{reqs.join(', ')}"
|
105
|
+
end
|
100
106
|
next
|
101
107
|
else
|
102
108
|
gem gemname, *reqs
|
data/lib/helpema/ssss.rb
CHANGED
@@ -14,9 +14,18 @@ module Helpema
|
|
14
14
|
pipe.puts options.fetch(:secret)
|
15
15
|
pipe.read.split.last(options[:shares])
|
16
16
|
end
|
17
|
-
def split(
|
18
|
-
|
19
|
-
|
17
|
+
def split(
|
18
|
+
secret:, threshold:,
|
19
|
+
shares:, token:nil,
|
20
|
+
level:nil,
|
21
|
+
hexmode:false
|
22
|
+
) = SSSS._split(
|
23
|
+
secret:secret,
|
24
|
+
threshold:threshold,
|
25
|
+
shares:shares,
|
26
|
+
token:token,
|
27
|
+
level:level,
|
28
|
+
hexmode:hexmode)
|
20
29
|
SSSS.define_command(:_combine,
|
21
30
|
cmd: 'ssss-combine', v: SSSS.version,
|
22
31
|
usage: {Q:true,t:2,x:false}, synonyms: {threshold: :t, hexmode: :x},
|
data/lib/helpema.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Helpema
|
2
|
-
VERSION = '3.
|
2
|
+
VERSION = '3.1.210909'
|
3
3
|
|
4
4
|
require_relative 'helpema/helpema'
|
5
5
|
|
6
6
|
autoload :SSSS, 'helpema/ssss.rb'
|
7
7
|
autoload :YouTubeDL, 'helpema/youtubedl.rb'
|
8
8
|
autoload :ZBar, 'helpema/zbar.rb'
|
9
|
+
autoload :GPG, 'helpema/gpg.rb'
|
9
10
|
end
|
10
11
|
|
11
12
|
# Requires:
|
@@ -16,3 +17,4 @@ end
|
|
16
17
|
#`zbarcam`
|
17
18
|
#`zbarimg`
|
18
19
|
#`gnome-screenshot`
|
20
|
+
#`gpg`
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helpema
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.210909
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- CarlosJHR64
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Meant to be an eclectic collection of useful single functions and wrappers.
|
@@ -21,6 +21,7 @@ extra_rdoc_files: []
|
|
21
21
|
files:
|
22
22
|
- README.md
|
23
23
|
- lib/helpema.rb
|
24
|
+
- lib/helpema/gpg.rb
|
24
25
|
- lib/helpema/helpema.rb
|
25
26
|
- lib/helpema/ssss.rb
|
26
27
|
- lib/helpema/youtubedl.rb
|
@@ -44,14 +45,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
45
|
- !ruby/object:Gem::Version
|
45
46
|
version: '0'
|
46
47
|
requirements:
|
47
|
-
- 'ruby: ruby 3.0.
|
48
|
+
- 'ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]'
|
48
49
|
- 'youtube-dl: 2021.06.06'
|
49
50
|
- 'ssss-split: 0.5'
|
50
51
|
- 'ssss-combine: 0.5'
|
51
52
|
- 'zbarcam: 0.23'
|
52
53
|
- 'zbarimg: 0.23'
|
53
54
|
- 'gnome-screenshot: gnome-screenshot 40.0'
|
54
|
-
|
55
|
+
- 'gpg: gpg (GnuPG) 2.2.27'
|
56
|
+
rubygems_version: 3.2.22
|
55
57
|
signing_key:
|
56
58
|
specification_version: 4
|
57
59
|
summary: Meant to be an eclectic collection of useful single functions and wrappers.
|