我使用crypt()
函数和命名-lcrypt
问题的编译标志是编译器说未定义的引用crypt()
。谁能告诉我我做错了什么?
生成文件
CC = gcc
CFLAGS=-Wall -lm -lcrypt
OBJS = get_passwords_hashed.o
PROG = get_passwords_hashed.exe
#adicionar or mudar o OBJS se tiver outras files para o programa
#GENERIC
all: ${PROG}
clean:
rm ${OBJS} *~ ${PROG}
${PROG}: ${OBJS}
${CC} ${OBJS} -o $@
.c.o:
${CC} $< -c -o $@
# $@ - turns .c into .o
###################################
#dependencias
so_final.o: get_passwords_hashed.c get_passwords_hashed.h
主程序
#include <stdio.h>
#include <string.h>
#include <crypt.h>
int testar_pass(char ant[],char (*pointer_hashes)[max_chars_string]){ // ponteiro para array de chars - char ** ant
char * password ;
char * encrypted;
password = malloc(strlen(ant)*sizeof(char)); //password calculada recebida anteriror
encrypted = malloc(strlen(ant)*sizeof(char));//hash
strcpy(password,ant);
encrypted = crypt(password,"10");
if(strcmp(*pointer_hashes,encrypted) == 0){
return 1;
}
else return 0;// devolve erro
}