md5sum of file in Linux C

前端 未结 5 1986
时光取名叫无心
时光取名叫无心 2020-12-08 15:01

I want to find md5sum of a file in Linux C, Is there any API where I can send file name to get md5sum of that file.

5条回答
  •  独厮守ぢ
    2020-12-08 15:19

    There's code here.

    Also, the openssl libs have md5 functions (from here):

    #include 
    #include 
    int main()
    {
        int n;
        MD5_CTX c;
        char buf[512];
        ssize_t bytes;
        unsigned char out[MD5_DIGEST_LENGTH];
    
        MD5_Init(&c);
        bytes=read(STDIN_FILENO, buf, 512);
        while(bytes > 0)
        {
            MD5_Update(&c, buf, bytes);
            bytes=read(STDIN_FILENO, buf, 512);
        }
    
        MD5_Final(out, &c);
    
        for(n=0; n

提交回复
热议问题