MD5 with global salt
Review this Ruby user-password code.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1require 'digest'
2
3class User < ApplicationRecord
4 def password=(raw)
5 self.password_digest = Digest::MD5.hexdigest(raw + SALT)
6 end
7
8 def authenticate(raw)
9 Digest::MD5.hexdigest(raw + SALT) == password_digest
10 end
11end
12
13SALT = ENV.fetch('PW_SALT') # one global salt for all users
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.