Sha256: 5b0a3a3e31498cef05d0585b8650af199eebf2e9b2e6ae80c6c661ca45158720

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require 'openssl'
require 'base64'
require 'covert/version'

#
# Covert - makes your string securely obfuscated.
#
module Covert
  class Error < StandardError; end

  autoload :Config, 'covert/config.rb'
  autoload :Hmac, 'covert/hmac.rb'
  autoload :Obfuscation, 'covert/obfuscation.rb'
  autoload :Obfuscate, 'covert/obfuscate.rb'
  autoload :Unobfuscate, 'covert/unobfuscate.rb'

  class << self
    attr_writer :config

    # @return [Config]
    def config
      @config ||= Config.new
    end

    # @return [Config]
    def reset
      @config = Config.new
    end

    def configure
      yield(config)
    end
  end

  # @param [String] str String for HMAC encoding
  # @example Generate HMAC code
  #   Covert.hmac("mystring") #=> "cddb0db23f469c8bf072b21fd837149bd6ace9ab771cceef14c9e517cc93282e"
  # @return [String] HMAC encoded string
  def self.hmac(str)
    Hmac.call(value: str)
  end

  # @param [String] str String to obfuscate
  # @example Obfuscate a String
  #   Covert.obfuscate("mystring") #=> "7hSfzDwp2JXZcieFpGCndA=="
  # @return [String] Obfuscated string
  def self.obfuscate(str)
    Obfuscate.call(value: str)
  end

  # @param [String] str Obfuscated string
  # @example Unobfuscate a String
  #   Covert.unobfuscate("7hSfzDwp2JXZcieFpGCndA==") #=> "mystring"
  # @return [String] Unobfuscated string
  def self.unobfuscate(str)
    Unobfuscate.call(value: str)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
covert-0.2.0 lib/covert.rb