首頁 美術繪圖 | 美術設計 | 熱門標籤 | 首選 | 首頁宣傳 | 近期作品 論壇: 發表 | 美術工作 | 美術比賽 | 展覽活動 | 美術相關 | 一般討論 | 美術同好 CG 討論 :: Photoshop | Painter | 3D 行動 | AMP

【 立即註冊 】 : 更改個人資料 : : 登入

會員名稱: 登入密碼: 保持登入

md5.c openssl/md5.h @ gcc link by using -l ssl -l crypto

發表新主題 回覆主題 討論區 Windows, Linux, Perl, PHP, C/C++, Driver, Web 理論、應用、硬體、軟體

| 1頁, 共1
人氣點閱:2759 發表人
md5.c openssl/md5.h @ gcc link by using -l ssl -l crypto 2013-10-01 11:26
分類: ✔️include ✔️include ✔️include ✔️include
個人: ✔️include ✔️include ✔️include ✔️include
/ / /

openssl/md5.h @ gcc, make using -l ssl -l crypto



代碼:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/md5.h>

char *str2md5(const char *str, int length)
{
    int n;
    MD5_CTX c;
    unsigned char digest[16];
    char *out = (char*)malloc(33);

    MD5_Init(&c);

    while (length > 0)
    {
        if (length > 512)
        {
            MD5_Update(&c, str, 512);
        } else
        {
            MD5_Update(&c, str, length);
        }
        length -= 512;
        str += 512;
    }

    MD5_Final(digest, &c);

    for (n = 0; n < 16; ++n) {
        snprintf(&(out[n*2]), 16*2, "%02x", (unsigned int)digest[n]);
    }

    return out;
}

int main(void)
{
    char *output = str2md5("vovo2000.com", strlen("vovo2000.com"));

    printf("%s\n", output);
    free(output);

    return 0;
}


How to
代碼:

$ gcc md5.c
md5.c:(.text+0x40): undefined reference to `MD5_Init'
md5.c:(.text+0x6c): undefined reference to `MD5_Update'
md5.c:(.text+0x90): undefined reference to `MD5_Update'
md5.c:(.text+0xc4): undefined reference to `MD5_Final'
collect2: ld returned 1 exit status

$ gcc md5.c -l ssl -l crypto
$ a.out

________________

美術插畫設計案子報價系統 v0.1 Beta
爪哇禾雀

Type



繪圖畫廊設計藝廊
攝影相簿留言板
最愛收藏分類標籤
暱稱: Type
註冊: 2002-11-30
發表: 11081
來自: vovo2000.com
V幣: 900806





資訊相關理論、技術、管理、應用、產品等
發表新主題 回覆主題