class SequelAuth::Providers::Scrypt

Attributes

key_len[W]
max_mem[W]
max_memfrac[W]
max_time[W]
salt_size[W]

Public Class Methods

defaults() click to toggle source
# File lib/sequel_auth/providers/scrypt.rb, line 54
def defaults
  {
    key_len: 32,
    salt_size: 8,
    max_time: 0.2,
    max_mem: 1024 * 1024,
    max_memfrac: 0.5
  }.freeze
end
encrypt(password) click to toggle source
# File lib/sequel_auth/providers/scrypt.rb, line 37
def encrypt(password)
  ::SCrypt::Password.create(
    password,
    key_len: key_len,
    salt_size: salt_size,
    max_mem: max_mem,
    max_memfrac: max_memfrac,
    max_time: max_time
  )
end
key_len() click to toggle source

Key length - length in bytes of generated key, from 16 to 512.

# File lib/sequel_auth/providers/scrypt.rb, line 12
def key_len
  @key_len ||= defaults[:key_len]
end
matches?(hash, password) click to toggle source
# File lib/sequel_auth/providers/scrypt.rb, line 48
def matches?(hash, password)
  ::SCrypt::Password.new(hash)==password
rescue ::SCrypt::Errors::InvalidHash
  false
end
max_mem() click to toggle source

Max memory - maximum memory usage. The minimum is always 1MB

# File lib/sequel_auth/providers/scrypt.rb, line 27
def max_mem
  @max_mem ||= defaults[:max_mem]
end
max_memfrac() click to toggle source

Max memory fraction - maximum memory out of all available. Always greater than zero and <= 0.5.

# File lib/sequel_auth/providers/scrypt.rb, line 33
def max_memfrac
  @max_memfrac ||= defaults[:max_memfrac]
end
max_time() click to toggle source

Max time - maximum time spent in computation

# File lib/sequel_auth/providers/scrypt.rb, line 22
def max_time
  @max_time ||= defaults[:max_time]
end
salt_size() click to toggle source

Salt size - size in bytes of random salt, from 8 to 32

# File lib/sequel_auth/providers/scrypt.rb, line 17
def salt_size
  @salt_size ||= defaults[:salt_size]
end