Sha256: 783a786cfcea85e6fd9efbddb62b3a761244692f5ecfe7d63b81eb4d3dc0e936

Contents?: true

Size: 667 Bytes

Versions: 2

Compression:

Stored size: 667 Bytes

Contents

module SecureHasher
  # Securely apply a one-way cryptographic hash.
  # 
  # @param password [String] Plaintext password.
  # @param salt     [String] Password salt. Default: +xx+
  # @return         [String]
  # @raise          [ArgumentError] No password provided. 
  # 
  # @example Basic Usage
  #   SecureHasher.hash('mypassword')
  #   # => "xx.sEzWY1w1qk"
  #
  # @example Advanced Usage
  #   SecureHasher.hash('mypassword', 'xy')
  #   # => "xyoxiBrqcbujE"
  #
  def self.secure_hash(password: false, salt: 'xx')
    # Must provide a password.
    raise Error, 'No password provided.' unless password
    # Hash password.
    password.crypt(salt)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
secure_hasher-1.0.1 lib/secure_hasher/hasher.rb
secure_hasher-1.0.0 lib/secure_hasher/hasher.rb