We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I would like to use this hash with sha256 or sha512. Can you help me?
Original issue reported on code.google.com by [email protected] on 30 Mar 2014 at 11:52
[email protected]
The text was updated successfully, but these errors were encountered:
*hash = encryption (Sorry, I misspelled.)
Original comment by [email protected] on 30 Mar 2014 at 11:54
Sorry, something went wrong.
Example with php: function encrypt($data, $password) { // Set a random salt $salt = openssl_random_pseudo_bytes(8); $salted = ''; $dx = ''; // Salt the key(176) and iv(16) = 192 while (strlen($salted) < 192) { $dx = hash(sha512, $dx.$password.$salt, true); $salted .= $dx; } $key = substr($salted, 0, 176); $iv = substr($salted, 176,16); $encrypted_data = openssl_encrypt($data, 'aes-256-cbc', $key, true, $iv); return base64_encode('Salted__' . $salt . $encrypted_data); } function decrypt($edata, $password) { $data = base64_decode($edata); $salt = substr($data, 8, 8); $ct = substr($data, 16); $rounds = 3; $data00 = $password.$salt; $sha512_hash = array(); $sha512_hash[0] = hash(sha512, $data00, true); $result = $sha512_hash[0]; for ($i = 1; $i < $rounds; $i++) { $sha512_hash[$i] = hash(sha512, $sha512_hash[$i - 1].$data00, true); $result .= $sha512_hash[$i]; } $key = substr($result, 0, 176); $iv = substr($result, 176,16); return openssl_decrypt($ct, 'aes-256-cbc', $key, true, $iv); }
Original comment by [email protected] on 30 Mar 2014 at 8:02
No branches or pull requests
Original issue reported on code.google.com by
[email protected]
on 30 Mar 2014 at 11:52The text was updated successfully, but these errors were encountered: