Q:

php openssl encrypt data with aes256 and use a sha256 hashed pass help!

openssl only accepting half of a sha256 hashed password
$encryptedkey = openssl_encrypt ($data, 'AES256', "$sha256", $raw_output = false);
hash looks like this:a0461cea77b9942addee32b2265b32ebcf150426e2490810938ab47206fd320b
its only accepting 32 characters of it:a0461cea77b9942addee32b2265b32eb
how can i fix this? thank you! 

edit: example: when decrypting the data if the hash does not mach after 32 character it will still decrypt it even if its wrong 
a0461cea77b9942addee32b2265b32ebcf150426e2490810938ab47206fd320b
a0461cea77b9942addee32b2265b32ebcf150426e24808019485b43406df3a9b
both will work when they shouldn't? 

A:

I'd guess you should pass the raw data, not an hexadecimal representation of it. I say this because 32*8=256, hence by reading 32 characters, the function is actually reading 256 bits.
Try passing pack("H*", $sha256) instead of $sha256.

