12.02.2016, 12:42
If there's any randomness involved then it can never be truly unique. The chance of a match is extremely small but it is still there nevertheless. Assuming MySQL, let the database generate the salt. Use an inline variable in the query so you don't have to fetch it to store it elsewhere.
Looks complicated, but once written shouldn't have to be changed ever again.
PHP код:
INSERT INTO `User` VALUES (NULL, 'name', 'email', UNIX_TIMESTAMP(), SHA1(CONCAT('password', @salt := SHA1(UUID()))), @salt);