From c0c3776ac651f40fd5f11d1a80c6856102b18ae8 Mon Sep 17 00:00:00 2001 From: Stricted Date: Sun, 12 Jul 2015 18:30:28 +0200 Subject: [PATCH] fix for php < 5.5.0 --- .gitignore | 1 + SpeedportHybrid.class.php | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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(); -- 2.20.1