ParagonIE\PasswordLock\PasswordLock::upgradeFromVersion1 PHP Method

upgradeFromVersion1() public static method

For migrating from an older version of the library
public static upgradeFromVersion1 ( string $password, string $ciphertext, string $oldKey, Defuse\Crypto\Key $newKey ) : string
$password string
$ciphertext string
$oldKey string
$newKey Defuse\Crypto\Key
return string
    public static function upgradeFromVersion1(string $password, string $ciphertext, string $oldKey, Key $newKey) : string
    {
        if (!self::decryptAndVerifyLegacy($password, $ciphertext, $oldKey)) {
            throw new \Exception('The correct password is necessary for legacy migration.');
        }
        $plaintext = Crypto::legacyDecrypt($ciphertext, $oldKey);
        return self::hashAndEncrypt($plaintext, $newKey);
    }