|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
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[1024];
void printHash(unsigned char *md, int len)
{
int i = 0;
for (i = 0; i < len; i++)
{
printf("%02x", md[i]);
sprintf(Buffer,"%02x",md[i]);
FileOpen.write(Buffer,strlen(Buffer));
}
printf("\n");
}
void myHash224()
{
SHA256_CTX c;
unsigned char md[SHA224_DIGEST_LENGTH];
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;
} |
|