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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 904b947a5cea2a83a12ee5b084f11a54ad980616
4
- data.tar.gz: 72bec3f5842e7a94d3cf1d89b6c818386a596309
3
+ metadata.gz: 3e9b36aa84775b25ffa8b27bdeab967f30915e0e
4
+ data.tar.gz: 553a0a3662e0ef4553113fbf6914f56287bcea02
5
5
  SHA512:
6
- metadata.gz: 68095f45e47b78a3b2e8d060e74caca8857ac71e74fbece088d8285d7113e4e43776f23799e877e8c135832234891d882dc2a77687677a7d1c31a95929b5c05d
7
- data.tar.gz: 8a15b95af63a3268152c8fa3dcd399c1c64238cea18b7347fcbed1b0f5ca6bd92c305424237ba1d212d97a0a9dfbfa726ccbd7c3a6fc56b41102e5f1d7310e3f
6
+ metadata.gz: 39e7292cca1cb5bb768eef00de348c4430ccf648ad5f6b3380927f99076f29fc62596cd5bc4383cf389053d0cc097dc6d4ad111367ed47299233eedc3c2b1299
7
+ data.tar.gz: 4336e185b7322d058a8370290f8f30d8d1f37c728815694c0807983201b84107417e95a998e375967a17027202d12179d4e5e1f519771923641b95b2a129c3a0
@@ -4,3 +4,4 @@ require "glib/value"
4
4
  require "glib/json_crawler"
5
5
 
6
6
  require 'glib/dynamic_text'
7
+ require 'glib/crypt'
@@ -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
@@ -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.67
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