wikk_aes_256 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 +4 -4
- data/History.txt +8 -0
- data/lib/wikk_aes_256.rb +10 -14
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dd425fdcb527392c69b96465b764aab84ef72a8f70420a98400ae7d6aea894b
|
4
|
+
data.tar.gz: 8e993f98f23cc6a309dbd5da231d7ef0cac18f6fac9941a5136ee4678e988f63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcfe57a6287556cfe0b1414fa2c8e417544e0e2f00ed159d2f889c097ca6c73512c552f510b3da7022fae48efbbef2cb25d4bb7761331dd4c8914acf14777c1d
|
7
|
+
data.tar.gz: bc83fcf0f6f2fefe986f2a194a5e8582cb410de4c1d006ea61a3179127102e23a6773f323ff927474743bebb7707bab720cf057edf40c4fafb675da3af702d71
|
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
robertburrowes Sat Apr 15 17:33:00 2023 +1200
|
2
|
+
Use SecureRandom for generating the key, if none given.
|
3
|
+
robertburrowes Sat Apr 15 17:30:45 2023 +1200
|
4
|
+
show encrypted text too.
|
5
|
+
robertburrowes Sun Jun 5 18:46:28 2022 +1200
|
6
|
+
ensure we use bash
|
7
|
+
robertburrowes Sun Jun 5 18:21:48 2022 +1200
|
8
|
+
#{PROJECT} release 0.1.7
|
1
9
|
robertburrowes Sun Jun 5 18:18:15 2022 +1200
|
2
10
|
left out require stringio
|
3
11
|
robertburrowes Sun Oct 25 22:11:06 2020 +1300
|
data/lib/wikk_aes_256.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'openssl'
|
2
|
-
require '
|
2
|
+
require 'securerandom'
|
3
3
|
require 'base64'
|
4
4
|
require 'stringio'
|
5
5
|
|
@@ -10,7 +10,7 @@ module WIKK
|
|
10
10
|
# @attr_reader [String] plain_text the decrypted text
|
11
11
|
# @attr_reader [String] cipher_text the encrypted text
|
12
12
|
class AES_256
|
13
|
-
VERSION = '0.1.
|
13
|
+
VERSION = '0.1.8'
|
14
14
|
AES_256_CBC = 'AES-256-CBC'
|
15
15
|
|
16
16
|
attr_reader :plain_text, :cipher_text
|
@@ -23,7 +23,7 @@ module WIKK
|
|
23
23
|
# Overwritten by auto generated iv, if key_string is nil. Recover with iv_to_str() or key_iv_to_s().
|
24
24
|
def initialize(key_string = nil, iv_string = nil)
|
25
25
|
if key_string.nil?
|
26
|
-
gen_key
|
26
|
+
gen_key(key_length: 32)
|
27
27
|
else
|
28
28
|
str_to_key(key_string)
|
29
29
|
end
|
@@ -35,13 +35,11 @@ module WIKK
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# Generates a new key
|
38
|
+
# Generates a new binary key in @key, using SecureRandom.
|
39
39
|
#
|
40
40
|
# @return [String] Binary string, @key
|
41
|
-
def gen_key
|
42
|
-
|
43
|
-
digest.update('symetric key')
|
44
|
-
return (@key = digest.digest)
|
41
|
+
def gen_key(key_length: 32)
|
42
|
+
@key = SecureRandom.gen_random(key_length)
|
45
43
|
end
|
46
44
|
|
47
45
|
# Convert key to a base64 string
|
@@ -132,13 +130,11 @@ module WIKK
|
|
132
130
|
@plain_text << decode_cipher.final
|
133
131
|
end
|
134
132
|
|
135
|
-
# Generates a
|
133
|
+
# Generates a random base64 key.
|
136
134
|
#
|
137
135
|
# @return [String] Base64 encoded string, @key
|
138
|
-
def self.gen_key_to_s
|
139
|
-
|
140
|
-
digest.update('symetric key')
|
141
|
-
return [ digest.digest ].pack('m').chomp
|
136
|
+
def self.gen_key_to_s(key_length: 32)
|
137
|
+
SecureRandom.base64(key_length)
|
142
138
|
end
|
143
139
|
|
144
140
|
# Generate random AES_256_CBC initialization vector.
|
@@ -148,7 +144,7 @@ module WIKK
|
|
148
144
|
return [ OpenSSL::Cipher.new(AES_256_CBC).random_iv ].pack('m').chomp
|
149
145
|
end
|
150
146
|
|
151
|
-
# Generates a new key using
|
147
|
+
# Generates a new key using Random string in @key, and random AES_256_CBC initialization vector in @iv
|
152
148
|
#
|
153
149
|
# @return [String,String] Base64 encoded string, @key;
|
154
150
|
# Base64 encoded initialization vector @iv
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikk_aes_256
|
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
|
- Rob Burrowes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hoe-yard
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
33
|
+
version: '3.25'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '3.
|
40
|
+
version: '3.25'
|
41
41
|
description: Class for AES 256 encryption of text.
|
42
42
|
email:
|
43
43
|
- r.burrowes@auckland.ac.nz
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
|
-
rubygems_version: 3.
|
81
|
+
rubygems_version: 3.3.7
|
82
82
|
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: Class for AES 256 encryption of text.
|