Reputation: 3
I want to use this library with MinGW and i've been trying to get the example to work.
Is this possible? I've had a look at using this but i've still not managed to do it.
Also, i'm welcome to alternative suggestions to sha1 hashing a string.
These are the errors I get when i try to compile sha1.cpp or the example program:
sha1.h:29:17: error: extra qualification 'SHA1::' on member 'lrot' [-fpermissive]
sha1.h:30:15: error: extra qualification 'SHA1::' on member 'storeBigEndianUint32' [-fpermissive]
sha1.h:31:15: error: extra qualification 'SHA1::' on member 'hexPrinter' [-fpermissive]
Thanks.
Part 2
#include <fstream>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include "sha1.h"
using namespace std;
int main(int argc, char *argv[])
{
const char* BYTES;
ifstream myFile("word.txt");
if (! myFile)
{
cout << "Error openning file" << endl;
return -1;
}
while (! myFile.eof())
{
getline(myFile, BYTES);
cout << BYTES << endl;
SHA1* sha1 = new SHA1();
sha1->addBytes(BYTES, strlen(BYTES));
unsigned char* digest = sha1->getDigest();
sha1->hexPrinter(digest, 20);
delete sha1;
free(digest);
}
myFile.close();
return 0;
}
Upvotes: 0
Views: 794
Reputation: 4728
The problem is in the extra "SHA1::" in the following lines in the file SHA1.h:
static Uint32 SHA1::lrot( Uint32 x, int bits );
static void SHA1::storeBigEndianUint32( unsigned char* byte, Uint32 num );
static void SHA1::hexPrinter( unsigned char* c, int l );
They should be modified into
static Uint32 lrot( Uint32 x, int bits );
static void storeBigEndianUint32( unsigned char* byte, Uint32 num );
static void hexPrinter( unsigned char* c, int l );
This because the functions are being defined in the class SHA1 and is unnecessary to define again that they are in SHA1. Note that the same unmodified file may be accepted by Visual Studio (I had the same problem few years ago)
Upvotes: 0