Class: Mack::Utils::Crypt::DefaultWorker
- Inherits:
-
Object
- Object
- Mack::Utils::Crypt::DefaultWorker
- Defined in:
- lib/mack-encryption/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 EzCrypto library and get’s it’s secret key from configatron.default_secret_key
Instance Method Summary collapse
-
#decrypt(x) ⇒ Object
Decrypts a string using the EzCrypto library and the secret key found in configatron.default_secret_key.
-
#encrypt(x) ⇒ Object
Encrypts a string using the EzCrypto library and the secret key found in configatron.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/mack-encryption/default_worker.rb', line 9 def initialize @aes_key = EzCrypto::Key.with_password(configatron.retrieve(:default_secret_key, String.randomize(40)), '_mackery_') end |
Instance Method Details
#decrypt(x) ⇒ Object
Decrypts a string using the EzCrypto library and the secret key found in configatron.default_secret_key
21 22 23 |
# File 'lib/mack-encryption/default_worker.rb', line 21 def decrypt(x) @aes_key.decrypt(x) end |
#encrypt(x) ⇒ Object
Encrypts a string using the EzCrypto library and the secret key found in configatron.default_secret_key
15 16 17 |
# File 'lib/mack-encryption/default_worker.rb', line 15 def encrypt(x) @aes_key.encrypt(x) end |