basic_ssl 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/basic_ssl.rb +2 -2
- metadata +1 -1
data/lib/basic_ssl.rb
CHANGED
@@ -11,12 +11,12 @@ module BasicSSL
|
|
11
11
|
aes_encrypt.key = aes_key = aes_encrypt.random_key
|
12
12
|
crypt = aes_encrypt.update(string) << aes_encrypt.final
|
13
13
|
encrypted_key = rsa_key(key).public_encrypt(aes_key)
|
14
|
-
Base64.encode64(encrypted_key)
|
14
|
+
[Base64.encode64(encrypted_key), Base64.encode64(crypt)].join("|")
|
15
15
|
end
|
16
16
|
|
17
17
|
## Return the raw string after decryption & decoding
|
18
18
|
def decrypt(key, string)
|
19
|
-
encrypted_key, crypt = string.split("
|
19
|
+
encrypted_key, crypt = string.split("|").map{|a| Base64.decode64(a) }
|
20
20
|
aes_key = rsa_key(key).private_decrypt(encrypted_key)
|
21
21
|
aes_decrypt = OpenSSL::Cipher::Cipher.new('AES-256-CBC').decrypt
|
22
22
|
aes_decrypt.key = aes_key
|