我链接-lcrypt,问题是我得到相同的加密,无论我的命令行参数。如果我改变盐,加密似乎只会改变。我的代码中会有什么会导致这个缺陷?为什么crypt函数在这里不起作用?
#define _XOPEN_SOURCE
#include <unistd.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char *enc[])
{
if (argc != 2)
{
printf("Improper command-line arguments\n");
return 1;
}
char *salt = "ZA";
printf("%s \n", crypt(*enc, salt));
}
更改第一个参数为enc [1]工作....但我还是不明白这一点:printf(“%s \ n”,crypt(“drain”,salt));无论第一个参数如何,我都会得到相同的加密,只有更改盐才能更改加密。这是为什么? – user3303819
@ user3303819 - 我不明白你的评论。 –