From: Stricted Date: Sun, 12 Jul 2015 16:30:28 +0000 (+0200) Subject: fix for php < 5.5.0 X-Git-Tag: 1.0.0~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c0c3776ac651f40fd5f11d1a80c6856102b18ae8;p=GitHub%2FStricted%2Fspeedport-hybrid-php-api.git fix for php < 5.5.0 --- diff --git a/.gitignore b/.gitignore index c11eeee..9dcd53d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ tests/config.php tests/test.php .komodotools *.komodoproject +rrd.php diff --git a/SpeedportHybrid.class.php b/SpeedportHybrid.class.php index 3e40be4..319b97d 100644 --- a/SpeedportHybrid.class.php +++ b/SpeedportHybrid.class.php @@ -95,7 +95,14 @@ class SpeedportHybrid { } // calculate derivedk - $this->derivedk = hash_pbkdf2('sha1', hash('sha256', $password), substr($this->challenge, 0, 16), 1000, 32); + if (version_compare(phpversion(), '5.5.0', '<')) { + require_once 'CryptLib/CryptLib.php'; + $pbkdf2 = new CryptLib\Key\Derivation\PBKDF\PBKDF2(); + $this->derivedk = $pbkdf2->derive(hash('sha256', $password), substr($this->challenge, 0, 16), 1000, 32); + } + else { + $this->derivedk = hash_pbkdf2('sha1', hash('sha256', $password), substr($this->challenge, 0, 16), 1000, 32); + } // get the csrf_token $this->token = $this->getToken();