Module: EncodedToken
- Extended by:
- ErrorMessages
- Defined in:
- lib/encoded_token.rb,
lib/encoded_token/utils.rb,
lib/encoded_token/cipher.rb,
lib/encoded_token/encoder.rb,
lib/encoded_token/version.rb,
lib/encoded_token/encryptor.rb,
lib/encoded_token/configuration.rb,
lib/encoded_token/error_messages.rb,
lib/encoded_token/encoder/utf8_decoder.rb,
lib/encoded_token/encoder/utf8_encoder.rb,
lib/encoded_token/encoder/legacy_decoder.rb,
lib/encoded_token/encoder/legacy_encoder.rb
Overview
EncodedToken
Encodes a UTF-8 String to produce a Secure Token, then decodes the Secure Token to return the original input.
-
The given input is encoded using a substitution cipher, then padded with alphanumeric characters to a random length.
-
Multiple substitution ciphers are used to improve security.
examples:
EncodedToken.encode(12345)
# => "b4ex6AEB62jlBGpVAGNou8iRmD7pnHGHafQlAHB7w0J"
EncodedToken.decode("b4ex6AEB62jlBGpVAGNou8iRmD7pnHGHafQlAHB7w0J")
# => "12345"
Defined Under Namespace
Modules: Encoder, ErrorMessages, Utils, VERSION Classes: Cipher, Configuration, Encryptor
Constant Summary
Constants included from ErrorMessages
ErrorMessages::CIPHER_ERRORS, ErrorMessages::CONFIG_ERRORS, ErrorMessages::ENCODED_TOKEN_ERRORS, ErrorMessages::ENCODER_ERRORS, ErrorMessages::ENCRYPTOR_ERRORS, ErrorMessages::ERROR_MESSAGES, ErrorMessages::V1_ENCODER_ERRORS
Class Method Summary collapse
-
.configuration ⇒ Configuration
Returns the configuration instance.
-
.configure {|block| ... } ⇒ void
Applies the provided block to the configuration and builds the ciphers.
-
.decode(token) ⇒ String?
Decodes a given token to the original string.
-
.decode!(token) ⇒ String
Decodes a given token to the original string, raising an exception if encountered.
-
.encode(input, encoder = :utf8) ⇒ String?
Encodes a given input to an encoded token.
-
.encode!(input, encoder = :utf8) ⇒ String
Encodes a given input to an encoded token, raising an exception if encountered.
-
.gem_version ⇒ Gem::Version
Returns the gem version.
Class Method Details
.configuration ⇒ Configuration
Returns the configuration instance.
56 57 58 |
# File 'lib/encoded_token.rb', line 56 def configuration @configuration ||= Configuration.instance end |
.configure {|block| ... } ⇒ void
This method returns an undefined value.
Applies the provided block to the configuration and builds the ciphers.
73 74 75 76 77 |
# File 'lib/encoded_token.rb', line 73 def configure yield(configuration) Encoder.build_ciphers! end |
.decode(token) ⇒ String?
Decodes a given token to the original string
124 125 126 |
# File 'lib/encoded_token.rb', line 124 def decode(token) Encoder.decode(token) end |
.decode!(token) ⇒ String
Decodes a given token to the original string, raising an exception if encountered
142 143 144 |
# File 'lib/encoded_token.rb', line 142 def decode!(token) Encoder.decode!(token) end |
.encode(input, encoder = :utf8) ⇒ String?
Encodes a given input to an encoded token.
90 91 92 |
# File 'lib/encoded_token.rb', line 90 def encode(input, encoder = :utf8) Encoder.encode(input, encoder) end |