Class: EncodedToken::Encryptor
- Inherits:
-
Object
- Object
- EncodedToken::Encryptor
- Includes:
- ErrorMessages
- Defined in:
- lib/encoded_token/encryptor.rb
Overview
EncodedToken::Encryptor
This class is responsible for encryption and decryption.
Constant Summary
Constants included from ErrorMessages
EncodedToken::ErrorMessages::CIPHER_ERRORS, EncodedToken::ErrorMessages::CONFIG_ERRORS, EncodedToken::ErrorMessages::ENCODED_TOKEN_ERRORS, EncodedToken::ErrorMessages::ENCODER_ERRORS, EncodedToken::ErrorMessages::ENCRYPTOR_ERRORS, EncodedToken::ErrorMessages::ERROR_MESSAGES, EncodedToken::ErrorMessages::V1_ENCODER_ERRORS
Instance Method Summary collapse
-
#cipher ⇒ Cipher
Returns the cipher instance.
-
#decrypt(encrypted_string) ⇒ String
Decrypts the given encrypted string.
-
#encrypt(original_string) ⇒ String
Encrypts the given original string.
-
#key ⇒ String
Returns the current root key.
-
#padding ⇒ Integer
Returns the random padding size for the current root key.
-
#valid_key?(key) ⇒ Boolean
Validates if the given key is part of the cipher's key list.
Instance Method Details
#cipher ⇒ Cipher
Returns the cipher instance.
86 87 88 |
# File 'lib/encoded_token/encryptor.rb', line 86 def cipher @cipher end |
#decrypt(encrypted_string) ⇒ String
Decrypts the given encrypted string.
56 57 58 |
# File 'lib/encoded_token/encryptor.rb', line 56 def decrypt(encrypted_string) process_chars(encrypted_string, :decrypt) end |
#encrypt(original_string) ⇒ String
Encrypts the given original string.
43 44 45 |
# File 'lib/encoded_token/encryptor.rb', line 43 def encrypt(original_string) process_chars(original_string, :encrypt) end |
#key ⇒ String
Returns the current root key.
76 77 78 |
# File 'lib/encoded_token/encryptor.rb', line 76 def key @root_key end |
#padding ⇒ Integer
Returns the random padding size for the current root key.
66 67 68 |
# File 'lib/encoded_token/encryptor.rb', line 66 def padding @cipher.padding end |
#valid_key?(key) ⇒ Boolean
Validates if the given key is part of the cipher's key list.
30 31 32 |
# File 'lib/encoded_token/encryptor.rb', line 30 def valid_key?(key) @cipher.valid_key?(key) end |