aion-enigma 0.0.1 → 1.0.0
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/README.md +4 -4
- data/lib/aion-enigma.rb +1 -1
- data/lib/{enigma.rb → aion_enigma.rb} +4 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0a89e14157738338871b5be211f170f342af292
|
4
|
+
data.tar.gz: 0f3d63e630154449524f83e6546829900f8c19fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b5abb7b2e2f31d6eed0841b803c36b6bbd8daee3fe3fe3d7261ad5dccc90c9183aa2b694930c7f869572192b8f8ff6c3ecc79fff2593acd067209a4c13cd8e5
|
7
|
+
data.tar.gz: 48970b3f4111afa321fbbf405bb4b46bb55bfc32f5727ca8f8b6bcab936992b38f85986beec3d5807b9c4e59306448a896bf3b94a2892fa4cd07b600dcc87a9e
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
1
|
+
AionEnigma
|
2
2
|
======
|
3
3
|
|
4
|
-
|
4
|
+
AionEnigma is a small utility for encrypting/decrypting a string based on a shared secret using AES-265-CBC.
|
5
5
|
|
6
6
|
Install
|
7
7
|
-------
|
@@ -18,9 +18,9 @@ Usage
|
|
18
18
|
secret_message = 'this is a secret message'
|
19
19
|
shared_secret = 'some shared secret'
|
20
20
|
|
21
|
-
enigma =
|
21
|
+
enigma = AionEnigma.new(shared_secret)
|
22
22
|
encrypted_message = enigma.encrypt(secret_message)
|
23
|
-
# encrypted_message ≈> '
|
23
|
+
# encrypted_message ≈> 'ivBsGDsQjG6ScC5wq7Q-2w~XgFz1c4mdDR_MhI0VkpvNMcINDHCrAXEb1RlzwXpuNU'
|
24
24
|
|
25
25
|
message = enigma.decrypt(encrypted_message)
|
26
26
|
# message => 'this is a secret message'
|
data/lib/aion-enigma.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require '
|
1
|
+
require 'aion_enigma'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'openssl'
|
2
2
|
require 'base64'
|
3
3
|
|
4
|
-
class
|
4
|
+
class AionEnigma
|
5
5
|
|
6
6
|
class EncryptError < StandardError; end
|
7
7
|
class DecryptError < StandardError; end
|
@@ -12,7 +12,7 @@ class Enigma
|
|
12
12
|
unless secret.is_a? String
|
13
13
|
fail ArgumentError, 'secret must be a string'
|
14
14
|
end
|
15
|
-
@key = Digest::
|
15
|
+
@key = Digest::SHA2.digest(secret)
|
16
16
|
end
|
17
17
|
|
18
18
|
# Encrypts a string.
|
@@ -89,7 +89,7 @@ class Enigma
|
|
89
89
|
# @param encrypted the encrypted bytes
|
90
90
|
# @return String with serialized iv and encrypted parameters
|
91
91
|
def pack(iv, encrypted)
|
92
|
-
[iv, encrypted].map { |x| Base64.
|
92
|
+
[iv, encrypted].map { |x| Base64.urlsafe_encode64(x).gsub('=','') }.join('~')
|
93
93
|
end
|
94
94
|
|
95
95
|
# Unpacking the encrypted_message into an array of iv and encrypted data.
|
@@ -103,7 +103,7 @@ class Enigma
|
|
103
103
|
# @param encrypted_message as outputted by Enigma#pack
|
104
104
|
# @return Array containing iv bytes and encrypted bytes
|
105
105
|
def unpack(encrypted_message)
|
106
|
-
encrypted_message.split('
|
106
|
+
encrypted_message.split('~').map { |m| Base64.urlsafe_decode64(m) }
|
107
107
|
end
|
108
108
|
|
109
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aion-enigma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Andersen
|
@@ -50,8 +50,8 @@ extra_rdoc_files: []
|
|
50
50
|
files:
|
51
51
|
- README.md
|
52
52
|
- lib/aion-enigma.rb
|
53
|
-
- lib/
|
54
|
-
homepage: https://github.com/aion-dk/enigma
|
53
|
+
- lib/aion_enigma.rb
|
54
|
+
homepage: https://github.com/aion-dk/aion-enigma
|
55
55
|
licenses:
|
56
56
|
- MIT
|
57
57
|
metadata: {}
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: '0'
|
72
72
|
requirements: []
|
73
73
|
rubyforge_project:
|
74
|
-
rubygems_version: 2.
|
74
|
+
rubygems_version: 2.6.13
|
75
75
|
signing_key:
|
76
76
|
specification_version: 4
|
77
77
|
summary: Encryption utility based on AES
|