app/models/cl_wiki/user.rb
# Generate a consistent key that can be used with Lockbox for encrypting
# content, and that is not persisted anywhere.
Generate a consistent key that can be used with Lockbox for encrypting
content, and that is not persisted anywhere.
Generate a consistent key that can be used with Lockbox for encrypting content and that is not persisted anywhere .
def derive_encryption_key(password)
      if authenticate(password)
        pass = 'secret'
        salt = 'static salt' 
        iter = 10_000
        hash = OpenSSL::Digest::SHA256.new
        len = hash.digest_length
        OpenSSL::KDF.pbkdf2_hmac(pass,
                                 salt: salt,
                                 iterations: iter,
                                 length: len,
                                 hash: hash)
      else
        raise 'Could not authenticate password'
      end
    end
def derive_encryption_key ( password ) if authenticate ( password ) pass = 'secret' salt = 'static salt' iter = 10_000 hash = OpenSSL :: Digest :: SHA256 . new len = hash . digest_length OpenSSL :: KDF . pbkdf2_hmac ( pass , salt : salt , iterations : iter , length : len , hash : hash ) else raise 'Could not authenticate password' end end
Generate a consistent key that can be used with Lockbox for encrypting
content, and that is not persisted anywhere.
Generate a consistent key that can be used with Lockbox for encrypting content and that is not persisted anywhere .
# so the same key is derived each time
password
<not_specific>