Beispiel #1
0
static void
print_sha1 (ImageInput *input)
{
    imagesize_t size = input->spec().image_bytes ();
    if (size >= std::numeric_limits<size_t>::max()) {
        printf ("    SHA1 digest: (unable to compute, image is too big)\n");
        return;
    }
    boost::scoped_array<unsigned char> buf(new unsigned char[(unsigned int)size]);
    input->read_image (input->spec().format, &buf[0]);
    CSHA1 sha;
    sha.Update ((const unsigned char *)&buf[0], (unsigned int) size);
    sha.Final ();
    std::string digest;
    sha.ReportHashStl (digest, CSHA1::REPORT_HEX_SHORT);
    printf ("    SHA-1: %s\n", digest.c_str());
}