MySQL: Generate Unique Salted, Hashed, Logins
February 9, 2015
Description
In the process of creating a SAML Identity Provider (IdP) & Service Provider (SP) solution for a unified login system, I needed to generate user information for testing. The applicable setting in the SAML IDP config/authsources file was:
So, I needed to load a username, hashed & salted password, and salt value for each row for testing.
MySQL Code
The following mysql code does the trick:
Explanation
The uid & password (first two lines) can be set to any value. The third line then sets the salt as a pseudo-random (enough for testing) MD5 hash. The final line inserts the uid and salt, as well as a hashed password created by concatenating the salt and password and then creating a SHA-256 hash.