public function XMLSecurityDSig::calculateDigest in SAML SP 2.0 Single Sign On (SSO) - SAML Service Provider 8
Parameters
string $digestAlgorithm:
string $data:
bool $encode:
Return value
string
Throws
Exception
2 calls to XMLSecurityDSig::calculateDigest()
File
- src/
XMLSecurityKey.php, line 1002
Class
Namespace
Drupal\miniorange_samlCode
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;
}