The input image is as usual.
Code: Select all
/*
Tim Hunter, cyclists@nc.rr.com
gcc `Magick-config --cflags --cppflags` test_encipher.c `Magick-config --ldflags --libs` -o test_encipher
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <magick/MagickCore.h>
int main(int argc,char **argv)
{
ImageInfo *info;
Image *image, *enc;
const char *image_sig, *enc_sig;
ExceptionInfo exception;
MagickBooleanType okay;
InitializeMagick(argv[0]);
puts(GetMagickVersion(NULL));
GetExceptionInfo(&exception);
info = CloneImageInfo(NULL);
strcpy(info->filename, "Flower_Hat.jpg");
image = ReadImage(info, &exception);
if (exception.severity != UndefinedException)
{
printf("ReadImage: %s: %s", exception.reason, exception.description);
exit(1);
}
enc = CloneImage(image, 0, 0, MagickTrue, &exception);
okay = EncipherImage(enc, "passphrase", &exception);
if (!okay)
{
exit(1);
}
okay = DecipherImage(enc, "passphrase", &exception);
if (!okay)
{
exit(1);
}
SignatureImage(image);
SignatureImage(enc);
image_sig = GetImageProperty(image, "signature");
enc_sig = GetImageProperty(enc, "signature");
printf("Image: %64s\n", image_sig);
printf("Enc: %64s\n", enc_sig);
DestroyExceptionInfo(&exception);
DestroyImageInfo(info);
DestroyImage(image);
DestroyImage(enc);
DestroyMagick();
exit(0);
}