krypton 0.1.7 → 0.1.8

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
- SHA1:
3
- metadata.gz: '0579a4d313ef1b13224ab7d42dffdb73df94c513'
4
- data.tar.gz: 0ccccc6b88bf586c28e973763697029fc3cd872f
2
+ SHA256:
3
+ metadata.gz: 8a86fd0d5ca7918e968df272fc4022b790c7b054691414801b03d68edbaa617d
4
+ data.tar.gz: fd6f830536481adb2705379402e30b1f792bc19b56a29615838086a62666a2a3
5
5
  SHA512:
6
- metadata.gz: 6983bd2935cee13d0323891201ccbc0d719ea62b3bad88531e69b561f255f75d3a289e8d6e1d1e29ba769fa7085737ded596db3ae5e8152d4447d758ee66423c
7
- data.tar.gz: 122c0be4b72fc4f0e4040d262e8f7f55250da9d2f6beb791f5dec92a7dcd5898561ecd83ecfde26103bebd6866a9f3faf17900e581f6a7abd25e791403db73d9
6
+ metadata.gz: 1f97e912553c4cef694404cddf467b22b0f7cb4b7cb795cc512dae98e148fbf09663473ea2f1426abced2710e3d15d46356c623c127b26ac9e51dd3b205f0a36
7
+ data.tar.gz: 440ce6cb87f58438d739143d38ea9a76c46b18e2ad138e37a8a3866db901a268152ef368c09b3de80b360144dc5685d501197a55035319763b7d0e0c76923409
@@ -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
- puts Paint[SecureRandom.uuid, '#2ecc71']
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
@@ -1,4 +1,4 @@
1
- VERSION = "0.1.7"
1
+ VERSION = "0.1.8"
2
2
  AUTHORS = {
3
3
  'Carter Brainerd' => '0xCB[at]protonmail[dot]com'
4
4
  }
@@ -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
- return Digest::SHA256.base64digest(data)
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
@@ -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 SHA256.
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.7
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: 2018-11-01 00:00:00.000000000 Z
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.13
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.