Class: Mack::Utils::Crypt::DefaultWorker
- Inherits:
-
Object
- Object
- Mack::Utils::Crypt::DefaultWorker
- Defined in:
- lib/utils/crypt/default_worker.rb
Overview
The default worker is one that is used when no other worker is specified or the specified worker does not exist. It uses the Crypt::Rijndael library and get’s it’s secret key from app_config.default_secret_key
Instance Method Summary collapse
-
#decrypt(x) ⇒ Object
Decrypts a string using the Crypt::Rijndael library and the secret key found in app_config.default_secret_key.
-
#encrypt(x) ⇒ Object
Encrypts a string using the Crypt::Rijndael library and the secret key found in app_config.default_secret_key.
-
#initialize ⇒ DefaultWorker
constructor
A new instance of DefaultWorker.
Constructor Details
#initialize ⇒ DefaultWorker
Returns a new instance of DefaultWorker.
9 10 11 |
# File 'lib/utils/crypt/default_worker.rb', line 9 def initialize @aes_key = ::Crypt::Rijndael.new(app_config.default_secret_key || (String.randomize(40))) end |
Instance Method Details
#decrypt(x) ⇒ Object
Decrypts a string using the Crypt::Rijndael library and the secret key found in app_config.default_secret_key
21 22 23 |
# File 'lib/utils/crypt/default_worker.rb', line 21 def decrypt(x) @aes_key.decrypt_string(x) end |
#encrypt(x) ⇒ Object
Encrypts a string using the Crypt::Rijndael library and the secret key found in app_config.default_secret_key
15 16 17 |
# File 'lib/utils/crypt/default_worker.rb', line 15 def encrypt(x) @aes_key.encrypt_string(x) end |