gen_salt() generates a random salt for password hashing with a specified algorithm. With Blowfish, call it for every new password so identical passwords produce different hashes; the resulting hash retains the salt for later verification. section 7.2.2
Salt a new password with Blowfish
INSERT INTO accounts (username, password_hash) VALUES ('ahamilton', crypt('SuperSecret123', gen_salt('bf'))); The generated password_hash contains the salt. During login, crypt('SuperSecret123', password_hash) reuses that stored salt and returns a matching hash.
