Class: Obfuscate::Crypt
- Inherits:
-
Object
- Object
- Obfuscate::Crypt
- Defined in:
- lib/obfuscate/crypt.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#exec_config ⇒ Object
readonly
Returns the value of attribute exec_config.
Instance Method Summary collapse
-
#clarify(text, override_mode = nil) ⇒ String
Clarify text.
-
#initialize(config) ⇒ Crypt
constructor
New instance of Obfuscate::Crypt.
-
#obfuscate(text, override_mode = nil) ⇒ String
Obfuscate text.
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
22 23 24 |
# File 'lib/obfuscate/crypt.rb', line 22 def config @config end |
#exec_config ⇒ Object (readonly)
Returns the value of attribute exec_config.
23 24 25 |
# File 'lib/obfuscate/crypt.rb', line 23 def exec_config @exec_config end |
Instance Method Details
#clarify(text, override_mode = nil) ⇒ String
Clarify text
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/obfuscate/crypt.rb', line 62 def clarify( text, override_mode = nil ) @exec_config = @config.apply( :mode => (override_mode || @config.mode) ) = text.to_s if @exec_config.encode << "=" if @exec_config.remove_trailing_equal? = Base64.urlsafe_decode64( ) end if @exec_config.mode == :string @crypt.decrypt_string( ) elsif @exec_config.mode == :block @crypt.decrypt_block( ).strip else raise "Unsupport Mode" end end |
#obfuscate(text, override_mode = nil) ⇒ String
Obfuscate text
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/obfuscate/crypt.rb', line 37 def obfuscate( text, override_mode = nil ) @exec_config = @config.apply( :mode => (override_mode || @config.mode) ) = nil if @exec_config.mode == :string = @crypt.encrypt_string(text) elsif @exec_config.mode == :block = @crypt.encrypt_block(text.to_s.ljust(8)) else raise "Unsupport Mode" end if @exec_config.encode = Base64.urlsafe_encode64().strip = .chomp("=") if @exec_config.remove_trailing_equal? end end |