-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
key based on password #161
Comments
thank you, and is it possible to use the generated key (with hash_pdkdf2) in Crypto::encrypt() somehow? |
$key = hash_pbkdf2(
'sha256',
$YOUR_USERS_PASSWORD_HERE,
$A_HARD_CODED_PASSWORD_SALT_MADE_OF_16_OR_MORE_RANDOM_BYTES_UNIQUE_PER_USER,
100000, // minimum 86000
16,
true
);
$cipher = Crypto::encrypt($message, $key);
$plain = Crypto::decrypt($cipher, $key);
var_dump($message === $cipher); // bool(true) |
Also, you want to use a CSPRNG for the salt. |
Thanks for the quick reply. I should have mentioned that I am using version 2.x of your library. Crypto::encrypt incorporates the following check:
Hence I need to transform the key generated by hash_pbkdf2 into a \Defuse\Crypto\Key somehow. |
Use |
@sstok I saw this functionality but it does not help me since I generate the key with hash_pbkdf2 which returns a string (or raw binary data). |
added the method CreateKeyBasedOnPassword which uses hash_pbkdf2 to generate a key. For a use case, see defuse#161
For now I am using the method I added in pull request #163 |
What you need is a long planed feature #5, not implemented yet in v2.0. Maybe your PR will push things forward a little. |
I am looking to use this library in a project I am working on but am stuck on the proper storage and usage of keys as well. I have scripts receiving strings of data from users on Android and iOS and I need to encrypt that data and store it in mysql. The data submitted by one user needs to be available to certain other users so I don't think encrypting with a users password will work. Most importantly the data needs to be absolutely secure and absolutely unreadable by me the only DBA. What would be the best approach for storing a key so that PHP can encrypt and decrypt POST and GET requests as needed without giving me any possible access to the data stored on my server. |
Revisit this when rewriting documentation #52 |
Hi,
I have the following scenario:
therefore I would like to know, how can I generate a key passed on a users password?
Cheers,
Robert
The text was updated successfully, but these errors were encountered: