This bit of code is something I came up with a few years ago. I was trying to come up with a way to generate passwords and secure database names when I decided to build a function to do it for me. Basically, it takes your input, hashes it, then suggests potential passwords or database names.
I have no illusions that this is the most groundbreaking code snippet out there, but hopefully it will be of some use to people.
Since creating the original ASP function, I have made a PHP version of it as well.
ASP
This script requires the SHA-256 Digest script developed by Frez Systems Limited. It contains a SHA-256 hashing algorithm written for ASP written in vbScript.
In a nutshell, the script below takes a string, runs it through the hash algorithm, and returns a list of suggested database names or passwords. You can choose from a 16, 10, or 8 digit password with characters chosen from the beginning, middle, or end of the returned hash.
PHP (Demo)
The PHP implementation of this script is nearly identical to the ASP one. The primary difference is that PHP has hash algorithms built in. This script fetches a list of the algorithms available on your server, and populates a dropdown box with them. This gives you the flexibility to use any number of different algorithms, increasing the security of your password or filename.
Final Note: As a rule, I would recommend that you not store databases and other secure files in a web accessible directory. While a hard-to-guess filename is a form of security, and is certainly an important part of it, security through obscurity is hardly a reliable method of preventing intrusion. As such, I strongly suggest that in addition to using secure names for important files, you store them above your root web directory whenever possible. Obviously this is not going to be possible all the time. However, if you get into the habit of storing secure files in a location that is not accessible via the web, you will have taken a large step in securing your information.