Parent

Class/Module Index [+]

Quicksearch

Authlogic::CryptoProviders::SCrypt

If you want a stronger hashing algorithm, but would prefer not to use BCrypt, SCrypt is another option. SCrypt is newer and less popular (and so less-tested), but it's designed specifically to avoid a theoretical hardware attack against BCrypt. Just as with BCrypt, you are sacrificing performance relative to SHA2 algorithms, but the increased security may well be worth it. (That performance sacrifice is the exact reason it's much, much harder for an attacker to brute-force your paswords). Decided SCrypt is for you? Just install the bcrypt gem:

gem install scrypt

Tell acts_as_authentic to use it:

acts_as_authentic do |c|
  c.crypto_provider = Authlogic::CryptoProviders::SCrypt
end

Constants

DEFAULTS

Attributes

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

Public Class Methods

encrypt(*tokens) click to toggle source

Creates an SCrypt hash for the password passed.

# File lib/authlogic/crypto_providers/scrypt.rb, line 54
def encrypt(*tokens)
  ::SCrypt::Password.create(join_tokens(tokens), :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/authlogic/crypto_providers/scrypt.rb, line 29
def key_len
  @key_len ||= DEFAULTS[:key_len]
end
matches?(hash, *tokens) click to toggle source

Does the hash match the tokens? Uses the same tokens that were used to encrypt.

# File lib/authlogic/crypto_providers/scrypt.rb, line 59
def matches?(hash, *tokens)
  hash = new_from_hash(hash)
  return false if hash.blank?
  hash == join_tokens(tokens)
end
max_mem() click to toggle source

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

# File lib/authlogic/crypto_providers/scrypt.rb, line 44
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/authlogic/crypto_providers/scrypt.rb, line 49
def max_memfrac
  @max_memfrac ||= DEFAULTS[:max_memfrac]
end
max_time() click to toggle source

Max time - maximum time spent in computation

# File lib/authlogic/crypto_providers/scrypt.rb, line 39
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/authlogic/crypto_providers/scrypt.rb, line 34
def salt_size
  @salt_size ||= DEFAULTS[:salt_size]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.