3 ms·
> The only thing that leaps out at me from the readme, is the lack of a suggested way to store/recover the salt? Ideally I'd see a function that takes a "passwo
by CiPHPerCoder 10y ago
> The only thing that leaps out at me from the readme, is the lack of a suggested way to store/recover the salt? Ideally I'd see a function that takes a "password" and some "plaintext" - generates a salt from an OS provided source, an IV (if applicable) and returns a package of the cipher-text along with the salt (and IV).
Generally you want to just do this once:
$key = KeyFactory::generateEncryptionKey();
KeyFactory::save($key, '/path/outside/webroot');
And from then on:
$key = KeyFactory::loadEncryptionKey('/path/outside/webroot');
Encryption typically never touches a password (although you can derive one from a password and salt if you so choose). The normal way of doing things is to just use a random key.
(My takeaway is: the README for v3 probably needs work to make this more clear.)
Thanks for the feedback! :)
- e12e 10y agoRight. Still, after your last edit, the last section (the example with a password derived key) -- still stands out from the rest of the otherwise excellent readme -- in that it's not actually a usable example. I mean the code (appears to) work - but it's not an actually usable example like the others. Because it leaves a lot of questions up in the air (or worse, for an untrained eye, it might lead to implementing "one-way" encryption, if real data is encrypted, and the salt thrown away...).