#include <openssl/aes.h>
#include <openssl/md5.h>
#include <openssl/sha.h>
/*
功能:进行sha1加密,返回hex转成的字符串
输入参数:str:字符指针
len:字符长度
out_data:加密之后的字符指针,长度必须是SHA_DIGEST_LENGTH =40
*/
int SHA1_encrypt( unsigned char *str,int len,signed char *out_data)
{
unsigned char md[SHA_DIGEST_LENGTH];
char tmp[3] = {'\0'};
char *buf =out_data;// (char*)malloc(33);
//bzero(buf,33);
SHA1(str,strlen(str),md);
int i = 0;
for(i=0;i<SHA_DIGEST_LENGTH;i++)
{
sprintf(tmp,"%2.2x",md[i]);
strcat(buf,tmp);
}
return 0;
}