在C crypt.h#$%^#$ ^% [英] #$%^#$^% with crypt.h in c
本文介绍了在C crypt.h#$%^#$ ^%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是低于code,我发现某处净,当我试图建立它我收到一个错误。编译就可以了。
以下是错误:
/tmp/ccCnp11F.o:在函数'主':。crypt.c :(文字+的0xf1):未定义的参考`地穴collect2:劳工处返回1退出状态
和这里是code:
的#include<&stdio.h中GT;
#包括LT&;&time.h中GT;
#包括LT&;&unistd.h中GT;
#包括LT&;&crypt.h GT; 诠释的main()
{
unsigned long类型的种子[2];
焦盐[] =$ 1 $ ........
为const char * const的seedchars =
./0123456789ABCDEFGHIJKLMNOPQRST
UVWXYZabcdefghijklmnopqrstuvwxyz;
字符*密码;
INT I; / *生成(不是很)随机种子。
你应该做的比这更好的... * /
种子[0] =时间(NULL);
种子[1] = GETPID()^(种子[0]≥&GT 14安培; 0x30000); / *把它变成从`seedchars'可打印字符。 * /
对于(i = 0; I< 8;我++)
盐[3 + I] = seedchars [(种子[I / 5]≥>(ⅰ%5)* 6)及0x3F的]; / *读入用户的密码和加密。 * /
密码=隐窝(将getpass(密码),盐); / *打印结果。 * /
看跌期权(密码);
返回0;
}
解决方案
crypt.c :(文字+的0xf1):未定义引用地穴
是一个连接器错误。
试着用 -lcrypt
链接: GCC crypt.c -lcrypt
I am using the below code that i found somewhere in the net and i am getting an error when i try to build it. The compilation is ok.
Here is the error:
/tmp/ccCnp11F.o: In function `main':
crypt.c:(.text+0xf1): undefined reference to `crypt'
collect2: ld returned 1 exit status
and here is the code:
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include <crypt.h>
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 better than this... */
seed[0] = time(NULL);
seed[1] = getpid() ^ (seed[0] >> 14 & 0x30000);
/* Turn it into printable characters from `seedchars'. */
for (i = 0; i < 8; i++)
salt[3+i] = seedchars[(seed[i/5] >> (i%5)*6) & 0x3f];
/* Read in the user's password and encrypt it. */
password = crypt(getpass("Password:"), salt);
/* Print the results. */
puts(password);
return 0;
}
解决方案
crypt.c:(.text+0xf1): undefined reference to 'crypt'
is a linker error.
Try linking with -lcrypt
: gcc crypt.c -lcrypt
.
这篇关于在C crypt.h#$%^#$ ^%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文