SHA1 hash calculation

hi

i want to generate SHA1 hash of string in Linux (atmark) and downloaded the XYSSL-0.9 version code for the same.i have the algorithm which takes file as argument and returns hash of file . And of same file while I generated the key using online tools then it doesn't match with my compiled library's result.
Do I need to change anything for it while compiling.
Secondly the data is equivalent to while doing memcpy in function rsa_pkcs1_verify(). In this func len is 35 and hasd_id is RSA_SHA1.

is there any conversion required on string before giving to hash generator???
if yes in which form its required??

Thanks,

Please show us your code. It is difficult to assist you without seeing what you are doing.

Can u please let me know the hashkey generated via sha1sum unix command will it be similar to the one generated by sha1 of xyssl library.
If not why there will be a difference.

In theory they should be the same. However,we cannot really help you unless you show us your code.

Hi.

I installed libxyssl-dev and it populated a directory with a number of examples. The one I found useful for this thread is a c code, uploaded (below) as a txt file. It is from:

/usr/share/doc/libxyssl-dev/examples/hash/sha1sum.c

on a GNU/Debian system:

OS, ker|rel, machine: Linux, 2.6.26-2-amd64, x86_64
Distribution        : Debian GNU/Linux 5.0

I wote a quick perl code and compared a few other methods to calculate the sha1 hash. The results are:

Whole: 15:0:15 of 4 lines in file "data1"
Now is the time
for all good men
to come to the aid
of their country.
 || end

-----
 Results, perl:
7de790fbe559d66cf890671ea2ef706281a1017f  data1 (perl)

-----
 Results, sha1sum:
7de790fbe559d66cf890671ea2ef706281a1017f  data1

-----
 Results, openssl OpenSSL 0.9.8g 19 Oct 2007:
SHA1(data1)= 7de790fbe559d66cf890671ea2ef706281a1017f

-----
 Results, sample c code ( 156 lines ):
-rwxr-xr-x 1 26335 Jul  3 13:14 a.out
7de790fbe559d66cf890671ea2ef706281a1017f  data1 (c code)

Your install will probably have placed relevant files in places different from those for my install.

Best wishes ... cheers, drl