public function generateDigest(DOMDocument $xml)
    {
        $xml = $xml->cloneNode(true);

        // strip Signature
        foreach ($this->getXPath($xml)->query('ds:Signature') as $node) {
            $node->parentNode->removeChild($node);
        }

        $message = $this->c14n($xml);

        return base64_encode(hash('sha256', $message, true));
    }