编译没有问题但是运行报错
0warning,0error,一运行就:出现错误,程序已停止运行,c++代码如下:#include <iostream>
#include <fstream>
#include <openssl/sha.h>
#include <openssl/crypto.h>// OPENSSL_cleanse
#pragma comment(lib, "libeay32.lib")
#pragma comment(lib, "ssleay32.lib")// 在本程序中, 可以注释掉这句
using namespace std;
char *orgStr = "1"; //待哈希的串
ofstream FileOpen;
char Buffer;
void printHash(unsigned char *md, int len)
{
int i = 0;
for (i = 0; i < len; i++)
{
printf("%02x", md);
sprintf(Buffer,"%02x",md);
FileOpen.write(Buffer,strlen(Buffer));
}
printf("\n");
}
void myHash224()
{
SHA256_CTX c;
unsigned char md;
SHA224((unsigned char *)orgStr, strlen(orgStr), md);
printHash(md, SHA224_DIGEST_LENGTH);
SHA224_Init(&c);
SHA224_Update(&c, orgStr, strlen(orgStr));
SHA224_Final(md, &c);
OPENSSL_cleanse(&c, sizeof(c));
}
int main()
{
long double i = 1;
for (i=1;i<10;i+1)
{
FileOpen.open("fuck.txt");
*orgStr = i;
myHash224();
}
return 0;
} 你把double赋值给char指针*orgStr = i; 这样会导致报错,虽然没有逻辑上的语法问题
页:
[1]