By default SHA will provide binary output. You should convert the data
in the output buffer to hex (i.e. printable characters). For an example
look in $OPENSSLDIR/apps/dgst.c at the bottom of the file. Here is the
code fragment.
if(binout) BIO_write(out, buf, len);
else
{
for (i=0; i<len; i++)
{
if (sep && (i != 0))
BIO_printf(out, ":");
BIO_printf(out, "%02x",buf[i]);
}
BIO_printf(out, "\n");
}
}
Riaan
On Fri, 2002-05-24 at 16:06, Stella Power wrote:
> Hi,
>
> I'm having problems with SHA1() and I'm hoping some of you might be able to
> help me out.
>
> I want to calculate the sha1 checksum of a file which i have mapped into
> memory (char *mapped_encrypted_file;). I use strlen on that to get its
> length (unsigned long maplength;). I also malloc space for my md (unsigned
> char *md;) as follows:
> md = (unsigned char*)malloc(BUFSIZE*sizeof(unsigned char));
> and call SHA1() by:
> SHA1((const unsigned char*)mapped_encrypted_file, maplength, md);
> However whenever I print md I just get weird characters - non-alphanumeric
> characters, $/\[ and other letters with accents.
>
> Is there something I'm doing wrong?
>
> Thanks
> Stella
> ______________________________________________________________________
> OpenSSL Project http://www.openssl.org
> User Support Mailing List [EMAIL PROTECTED]
> Automated List Manager [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]