Getting hash of a binary file C

后端 未结 4 1210
清歌不尽
清歌不尽 2021-01-14 21:05

I want to get hash of a binary file whose name I have. I have tried the following, but then realized that SHA1() is returning hash value for the string ( name o

4条回答
  •  鱼传尺愫
    2021-01-14 21:15

    I don't know how your SHA1() function works (is it from libssl?), but I assume that by

    SHA1((unsigned char *)fileName, strlen(fileName),hash);

    you are hashing file name, so /bin/ls string. You need to read file content byte by byte into a buffer and hash it.

提交回复
热议问题