krypton 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/krypton +27 -0
- data/lib/core.rb +2 -1
- data/lib/core/base64.rb +12 -0
- data/lib/core/constants.rb +1 -1
- data/lib/core/text.rb +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0579a4d313ef1b13224ab7d42dffdb73df94c513'
|
4
|
+
data.tar.gz: 0ccccc6b88bf586c28e973763697029fc3cd872f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6983bd2935cee13d0323891201ccbc0d719ea62b3bad88531e69b561f255f75d3a289e8d6e1d1e29ba769fa7085737ded596db3ae5e8152d4447d758ee66423c
|
7
|
+
data.tar.gz: 122c0be4b72fc4f0e4040d262e8f7f55250da9d2f6beb791f5dec92a7dcd5898561ecd83ecfde26103bebd6866a9f3faf17900e581f6a7abd25e791403db73d9
|
data/Gemfile.lock
CHANGED
data/bin/krypton
CHANGED
@@ -28,6 +28,10 @@ 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
|
32
|
+
options[:urlsafe] = true
|
33
|
+
end
|
34
|
+
|
31
35
|
opts.on('--verbose', 'Run verbosely') do
|
32
36
|
$verbose = true
|
33
37
|
end
|
@@ -47,6 +51,7 @@ OptionParser.new do |opts|
|
|
47
51
|
|
48
52
|
end.parse!(ARGV)
|
49
53
|
|
54
|
+
# Tasks loop
|
50
55
|
while (opt = ARGV.shift) do
|
51
56
|
case opt
|
52
57
|
|
@@ -68,6 +73,7 @@ while (opt = ARGV.shift) do
|
|
68
73
|
end
|
69
74
|
exit 0
|
70
75
|
|
76
|
+
|
71
77
|
# HASHING
|
72
78
|
when 'hash'
|
73
79
|
|
@@ -81,8 +87,10 @@ while (opt = ARGV.shift) do
|
|
81
87
|
puts "#{data + ' => '}#{Paint[result.strip, '#2ecc71']}"
|
82
88
|
end
|
83
89
|
exit 0
|
90
|
+
|
84
91
|
when 'uuid'
|
85
92
|
puts Paint[SecureRandom.uuid, '#2ecc71']
|
93
|
+
|
86
94
|
when 'totp'
|
87
95
|
if ARGV.length == 2
|
88
96
|
puts "You need a secret to generate a totp."
|
@@ -96,6 +104,25 @@ while (opt = ARGV.shift) do
|
|
96
104
|
end
|
97
105
|
exit 0
|
98
106
|
end
|
107
|
+
|
108
|
+
when 'b64e'
|
109
|
+
data = ARGV[ARGV.length - 1] || gets
|
110
|
+
if options[:std]
|
111
|
+
puts Krypton::B64.encode(data, options[:urlsafe])
|
112
|
+
else
|
113
|
+
puts "#{data + ' => ' + Paint[Krypton::B64.encode(data, options[:urlsafe]),'#2ecc71']}"
|
114
|
+
end
|
115
|
+
exit 0
|
116
|
+
|
117
|
+
when 'b64d'
|
118
|
+
data = ARGV[ARGV.length - 1] || gets
|
119
|
+
if options[:std]
|
120
|
+
puts Krypton::B64.decode(data, options[:urlsafe])
|
121
|
+
else
|
122
|
+
puts "#{data + ' => ' + Paint[Krypton::B64.decode(data, options[:urlsafe]),'#2ecc71']}"
|
123
|
+
end
|
124
|
+
exit 0
|
125
|
+
|
99
126
|
else
|
100
127
|
puts "#{opt} is not a valid action!"
|
101
128
|
exit 1
|
data/lib/core.rb
CHANGED
@@ -7,8 +7,9 @@ require 'rotp'
|
|
7
7
|
|
8
8
|
# lib files
|
9
9
|
require_relative './core/constants.rb'
|
10
|
-
require_relative './core/
|
10
|
+
require_relative './core/base64.rb'
|
11
11
|
require_relative './core/text.rb'
|
12
|
+
require_relative './core/aes.rb'
|
12
13
|
require_relative './core/sha.rb'
|
13
14
|
|
14
15
|
module Krypton
|
data/lib/core/base64.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
module Krypton
|
2
|
+
# This class contains wrapper functions around the '[en|de]code64 functions in the 'base64' library
|
3
|
+
class B64
|
4
|
+
def self.encode(data, urlsafe=false)
|
5
|
+
urlsafe ? Base64.urlsafe_encode64(data) : Base64.encode64(data)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.decode(data, urlsafe=false)
|
9
|
+
urlsafe ? Base64.urlsafe_decode64(data) : Base64.decode64(data)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/core/constants.rb
CHANGED
data/lib/core/text.rb
CHANGED
@@ -9,9 +9,11 @@ TASKS_HELP =
|
|
9
9
|
hash Hash a given message with SHA256.
|
10
10
|
uuid Generate a random UUID.
|
11
11
|
totp Generate a Time-based One Time Password.
|
12
|
+
b64e Encode data in base64
|
13
|
+
b64d Decode base64 data
|
12
14
|
|
13
15
|
#{Paint['Examples', '#95a5a6']}
|
14
16
|
#{Paint['$ krypton encrypt "mymessage" "mykey"', '#2ecc71']} #{Paint['=> ckhJWXcyTE1leENLOWpBQzJWbElMdz09Cg==', '#95a5a6']}
|
15
17
|
#{Paint['$ krypton hash "mymessage"', '#2ecc71']} => #{Paint['S3ONp9WM7/rCMeuUnvWDzp5dxbuSVsOV6bI5AJvRqCc=', '#95a5a6']}
|
16
|
-
#{Paint['$ krypton totp "mygreatsecret"']} => #{Paint['778501', '#95a5a6']}
|
18
|
+
#{Paint['$ krypton totp "mygreatsecret"', '#2ecc71']} => #{Paint['778501', '#95a5a6']}
|
17
19
|
}
|
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.7
|
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
|
+
date: 2018-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- krypton.gemspec
|
147
147
|
- lib/core.rb
|
148
148
|
- lib/core/aes.rb
|
149
|
+
- lib/core/base64.rb
|
149
150
|
- lib/core/constants.rb
|
150
151
|
- lib/core/sha.rb
|
151
152
|
- lib/core/text.rb
|