MarkR wrote:What is the use-case for having stuff encrypted / decrypted by PHP anyway?
I can think of two:
You don't entirely trust everyone who has access to your user database, so you hash the passwords stored therein. Once those passwords have been obtained, they could be impersonated not only at the site in question but (given a bit of data mining) at other sites on which the users are registered with the same password (people have a tendency to repeat passwords). Of course, brute-forcing the hashes is likely to turn up quite a few of those passwords anyway, but the only defence against that is for users not to pick easy passwords in the first place. (It should go without saying that hash algorithms are not designed for "secure storage" of passwords.)
Write-only storage that is intended only for later access offsite. This assumes that no-one can obtain the plaintext prior to its encryption, and requires the use of an asymmetric cipher for which the decrypt key is kept offsite.
Obviously, halojoy's code serves neither case.
halojoy wrote:especially when very long texts/strings.
Ooh, that sounds like fun; can we see one of these very long texts/strings?