defuse / php-encryption

Simple Encryption in PHP.
MIT License
3.78k stars 308 forks source link

ChangePassword method fail? #490

Closed RustieNewton closed 1 year ago

RustieNewton commented 2 years ago

The change password method breaks the process, even with a try catch block, but creating random password and unlocking are fine.

$a = KeyProtectedByPassword::loadFromAsciiSafeString($userdata['protectedKey']); //ok $a->changePassword( $password, $_REQUEST['newPassword'] ); echo $a->saveToAsciiSafeString(); //fail

However unlocking is fine ...
$a = KeyProtectedByPassword::loadFromAsciiSafeString($userdata['protectedKey']); //ok $a->unlockKey($_REQUEST['oldPassword']); //ok echo $a->saveToAsciiSafeString(); //ok

RustieNewton commented 2 years ago

//a simpler way of putting this apparent bug $passwordA = "xxx"; $passwordB = "yyy"; $protectedKey = KeyProtectedByPassword::createRandomPasswordProtectedKey($passwordA); //ok $new = $protectedKey->changePassword($passwordA, $passwordB ); //breaks

defuse commented 1 year ago

Sorry for the super slow response. Your example code runs without error for me. If you are still facing this issue, is there any error output or logs from PHP from the call that breaks?

defuse commented 1 year ago

I'm going to close this but feel free to re-open it if you're still encountering a bug.