From e6c87ad276d6c783f1ac640c3b49874b8e1942a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Mon, 3 Mar 2008 07:27:57 +0000 Subject: [PATCH] Adding the hash() method if it is does not exists - work around for older versions of php git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@337 44740490-163a-0410-bde0-09ae8108e29a --- lib/xmlseclibs.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/xmlseclibs.php b/lib/xmlseclibs.php index e9e727d8c..7e65d0be8 100644 --- a/lib/xmlseclibs.php +++ b/lib/xmlseclibs.php @@ -45,6 +45,21 @@ Functions to generate simple cases of Exclusive Canonical XML - Callable functio i.e.: $canonical = C14NGeneral($domelement, TRUE); */ + + +/** + * Older versions of PHP does not have the hash function, so we implement it + * if it does not exists + */ +if(!function_exists('hash')) { + function hash($algo, $data, $raw_output = 0) { + if($algo == 'md5') return(md5($data, $raw_output)); + if($algo == 'sha1') return(sha1($data, $raw_output)); + throw new Exception('xmlseclibs added hash() method: Hashing algoritm: ' . $algo . ' is not implemented'); + } +} + + /* helper function */ function sortAndAddAttrs($element, $arAtts) { $newAtts = array(); -- GitLab