Tag: crypt

在OS X上使用crypt_r

我想在Mac OS X 10.8.2上使用crypt_r函数 #define _GNU_SOURCE #include 产生 crypt.h: No such file or directory 我在哪里可以获得crypt.h文件? 还是我错了? 编辑问题 – 具体例子 #include #include int main(){ struct crypt_data * data = (struct crypt_data *) malloc(sizeof(struct crypt_data)); char * testhash; testhash = crypt_r(“string”, “sa”, data); free(data); return 0; } 产生 gcc test.c -Wall test.c: In function ‘main’: test.c:5: error: […]

对“crypt”的未定义引用

我正在使用下面的代码,我在网络的某个地方找到了,当我尝试构建它时,我收到了一个错误。 编译没问题。 这是错误: /tmp/ccCnp11F.o: In function `main’: crypt.c:(.text+0xf1): undefined reference to `crypt’ collect2: ld returned 1 exit status 这是代码: #include #include #include #include int main() { unsigned long seed[2]; char salt[] = “$1$……..”; const char *const seedchars = “./0123456789ABCDEFGHIJKLMNOPQRST” “UVWXYZabcdefghijklmnopqrstuvwxyz”; char *password; int i; /* Generate a (not very) random seed. You should do it […]

crypt函数和链接错误“未定义引用’crypt’”

我在c中使用了crypt函数来加密给定的字符串。 我写了以下代码, #include #include int main() { printf(“%s\n”,crypt(“passwd”,1000)); } 但是上面的代码引发了一个错误,“未定义引用`crypt’”。 上面的代码有什么问题。 提前致谢。