public function XMLSecurityDSig::calculateDigest in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 7
Parameters
string $digestAlgorithm:
string $data:
bool $encode:
Return value
string
Throws
Exception
2 calls to XMLSecurityDSig::calculateDigest()
- XMLSecurityDSig::addRefInternal in includes/
XMLSecurityKey.php - XMLSecurityDSig::validateDigest in includes/
XMLSecurityKey.php
File
- includes/
XMLSecurityKey.php, line 1035
Class
Code
public function calculateDigest($digestAlgorithm, $data, $encode = true) {
switch ($digestAlgorithm) {
case self::SHA1:
$alg = 'sha1';
break;
case self::SHA256:
$alg = 'sha256';
break;
case self::SHA384:
$alg = 'sha384';
break;
case self::SHA512:
$alg = 'sha512';
break;
case self::RIPEMD160:
$alg = 'ripemd160';
break;
default:
throw new Exception("Cannot validate digest: Unsupported Algorithm <{$digestAlgorithm}>");
}
$digest = hash($alg, $data, true);
if ($encode) {
$digest = base64_encode($digest);
}
return $digest;
}