krypton 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/krypton +15 -4
- data/lib/core/constants.rb +1 -1
- data/lib/core/sha.rb +12 -2
- data/lib/core/text.rb +4 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8a86fd0d5ca7918e968df272fc4022b790c7b054691414801b03d68edbaa617d
|
4
|
+
data.tar.gz: fd6f830536481adb2705379402e30b1f792bc19b56a29615838086a62666a2a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f97e912553c4cef694404cddf467b22b0f7cb4b7cb795cc512dae98e148fbf09663473ea2f1426abced2710e3d15d46356c623c127b26ac9e51dd3b205f0a36
|
7
|
+
data.tar.gz: 440ce6cb87f58438d739143d38ea9a76c46b18e2ad138e37a8a3866db901a268152ef368c09b3de80b360144dc5685d501197a55035319763b7d0e0c76923409
|
data/bin/krypton
CHANGED
@@ -28,7 +28,7 @@ OptionParser.new do |opts|
|
|
28
28
|
options[:raw] = true
|
29
29
|
end
|
30
30
|
|
31
|
-
opts.on('-u', '--urlsafe', 'Make output data URL safe (base64)') do
|
31
|
+
opts.on('-u', '--urlsafe', 'Make output data URL safe (base64) if applicable') do
|
32
32
|
options[:urlsafe] = true
|
33
33
|
end
|
34
34
|
|
@@ -89,8 +89,12 @@ while (opt = ARGV.shift) do
|
|
89
89
|
exit 0
|
90
90
|
|
91
91
|
when 'uuid'
|
92
|
-
|
93
|
-
|
92
|
+
if options[:std]
|
93
|
+
puts SecureRandom.uuid
|
94
|
+
else
|
95
|
+
puts Paint[SecureRandom.uuid, '#2ecc71']
|
96
|
+
end
|
97
|
+
|
94
98
|
when 'totp'
|
95
99
|
if ARGV.length == 2
|
96
100
|
puts "You need a secret to generate a totp."
|
@@ -122,7 +126,14 @@ while (opt = ARGV.shift) do
|
|
122
126
|
puts "#{data + ' => ' + Paint[Krypton::B64.decode(data, options[:urlsafe]),'#2ecc71']}"
|
123
127
|
end
|
124
128
|
exit 0
|
125
|
-
|
129
|
+
when 'sum'
|
130
|
+
filename = ARGV[ARGV.length - 1] || gets
|
131
|
+
if options[:std]
|
132
|
+
puts Krypton::SHA.checksum(filename, options[:raw])
|
133
|
+
else
|
134
|
+
puts "#{filename} => #{Paint[Krypton::SHA.checksum(filename, options[:raw]), '#2ecc71']}"
|
135
|
+
end
|
136
|
+
exit 0
|
126
137
|
else
|
127
138
|
puts "#{opt} is not a valid action!"
|
128
139
|
exit 1
|
data/lib/core/constants.rb
CHANGED
data/lib/core/sha.rb
CHANGED
@@ -4,7 +4,17 @@ module Krypton
|
|
4
4
|
class SHA
|
5
5
|
def self.hash(data, raw=false)
|
6
6
|
return Digest::SHA256.hexdigest(data) if raw
|
7
|
-
|
7
|
+
Digest::SHA256.base64digest(data)
|
8
8
|
end
|
9
|
+
|
10
|
+
def self.checksum(filepath, raw=false)
|
11
|
+
unless File.exist?(filepath)
|
12
|
+
puts "Error: File not found at " + filepath
|
13
|
+
return 1
|
14
|
+
end
|
15
|
+
|
16
|
+
return Digest::SHA256.hexdigest(File.read(filepath)) if raw
|
17
|
+
Digest::SHA256.base64digest(File.read(filepath))
|
18
|
+
end
|
19
|
+
end
|
9
20
|
end
|
10
|
-
end
|
data/lib/core/text.rb
CHANGED
@@ -6,11 +6,12 @@ end
|
|
6
6
|
TASKS_HELP =
|
7
7
|
%Q{ encrypt Encrypt the message with the given key (AES).
|
8
8
|
decrypt Decrypt the message with the given key (AES).
|
9
|
-
hash Hash a given message with
|
9
|
+
hash Hash a given message with SHA-256.
|
10
|
+
sum Retrieve the SHA-256 checksum of a given file.
|
10
11
|
uuid Generate a random UUID.
|
11
12
|
totp Generate a Time-based One Time Password.
|
12
|
-
b64e Encode data in base64
|
13
|
-
b64d Decode base64 data
|
13
|
+
b64e Encode data in base64.
|
14
|
+
b64d Decode base64 data.
|
14
15
|
|
15
16
|
#{Paint['Examples', '#95a5a6']}
|
16
17
|
#{Paint['$ krypton encrypt "mymessage" "mykey"', '#2ecc71']} #{Paint['=> ckhJWXcyTE1leENLOWpBQzJWbElMdz09Cg==', '#95a5a6']}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: krypton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cbrnrd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
174
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.6
|
175
|
+
rubygems_version: 2.7.6
|
176
176
|
signing_key:
|
177
177
|
specification_version: 4
|
178
178
|
summary: A command-line tool for easy encryption and decryption of data.
|