glib-web 0.4.67 → 0.4.68
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/glib-web.rb +1 -0
- data/lib/glib/crypt.rb +1 -0
- data/lib/glib/crypt/utils.rb +26 -0
- data/lib/glib/dynamic_text.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e9b36aa84775b25ffa8b27bdeab967f30915e0e
|
4
|
+
data.tar.gz: 553a0a3662e0ef4553113fbf6914f56287bcea02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39e7292cca1cb5bb768eef00de348c4430ccf648ad5f6b3380927f99076f29fc62596cd5bc4383cf389053d0cc097dc6d4ad111367ed47299233eedc3c2b1299
|
7
|
+
data.tar.gz: 4336e185b7322d058a8370290f8f30d8d1f37c728815694c0807983201b84107417e95a998e375967a17027202d12179d4e5e1f519771923641b95b2a129c3a0
|
data/lib/glib-web.rb
CHANGED
data/lib/glib/crypt.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative './crypt/utils'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Glib
|
2
|
+
module Crypt
|
3
|
+
class Utils
|
4
|
+
def self.encrypt(original_message, encryption_secret, encryption_salt)
|
5
|
+
encryptor = message_encryptor(encryption_secret, encryption_salt)
|
6
|
+
CGI.escape(encryptor.encrypt_and_sign(original_message))
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.decrypt(encrypted_message, encryption_secret, encryption_salt)
|
10
|
+
encryptor = message_encryptor(encryption_secret, encryption_salt)
|
11
|
+
begin
|
12
|
+
encryptor.decrypt_and_verify(CGI.unescape(encrypted_message))
|
13
|
+
rescue ActiveSupport::MessageEncryptor::InvalidMessage
|
14
|
+
nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def self.message_encryptor(encryption_secret, encryption_salt)
|
20
|
+
key_generator = ActiveSupport::KeyGenerator.new(encryption_secret, iterations: 1000)
|
21
|
+
key_secret = key_generator.generate_key(encryption_salt, 32)
|
22
|
+
ActiveSupport::MessageEncryptor.new(key_secret, digest: 'SHA1', serializer: JSON)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/glib/dynamic_text.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require_relative './dynamic_text/config'
|
1
|
+
require_relative './dynamic_text/config'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glib-web
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.68
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -192,6 +192,8 @@ files:
|
|
192
192
|
- lib/generators/templates/database.yml
|
193
193
|
- lib/generators/templates/dynamic_text.rb
|
194
194
|
- lib/glib-web.rb
|
195
|
+
- lib/glib/crypt.rb
|
196
|
+
- lib/glib/crypt/utils.rb
|
195
197
|
- lib/glib/dynamic_text.rb
|
196
198
|
- lib/glib/dynamic_text/config.rb
|
197
199
|
- lib/glib/engine.rb
|