ircmaxell / PHP-PasswordLib

A library for generating and validating passwords
373 stars 61 forks source link

Why the priority on BCMath in BigMath instead of GMP? #8

Closed meghuizen closed 11 years ago

meghuizen commented 11 years ago

Looking at this page: http://phpseclib.sourceforge.net/math/intro.html I see that GMP gives better performance then BCMath.

Why then does BigMath::createFromServerConfiguration() have this order?

if (extension_loaded('bcmath')) {
    return new \PasswordLib\Core\BigMath\BCMath();
} elseif (extension_loaded('gmp')) {
    return new \PasswordLib\Core\BigMath\GMP();
} else {
    return new \PasswordLib\Core\BigMath\PHPMath();
}

I suggest to turn it around. Or are there reasons for priority on bcmath?

ircmaxell commented 11 years ago

The only reason for the current priority is that the system I was on did not have gmp, so I tested bcmath far more deeply. I have no issue swapping them if it's that big of a difference...

ghost commented 11 years ago

According to performance testing done for phpseclib, it seems like a very good idea to prioritize the gmp extension first.

EDIT: I need to learn how to read.

ircmaxell commented 11 years ago

Implemented in PR#10