can i get some help?

Started by
14 comments, last by Dead_Zone 18 years, 1 month ago
heres my errors .\main.cpp(47) : error C2227: left of '->md5' must point to class/struct/union/generic type type is 'int *' .\main.cpp(47) : error C2228: left of '.Update' must have class/struct/union .\main.cpp(47) : error C2065: 'garble1' : undeclared identifier .\main.cpp(48) : error C2227: left of '->md5' must point to class/struct/union/generic type type is 'int *' .\main.cpp(48) : error C2228: left of '.Update' must have class/struct/union .\main.cpp(48) : error C2065: 'garble2' : undeclared identifier .\main.cpp(49) : error C2227: left of '->md5' must point to class/struct/union/generic type type is 'int *' .\main.cpp(49) : error C2228: left of '.Update' must have class/struct/union .\main.cpp(49) : error C2070: ''unknown-type'': illegal sizeof operand .\main.cpp(49) : error C2065: 'garble3' : undeclared identifier heres the code thats getting those errors garble1 -> md5.Update(hash, sizeof(hash)); md5.Final(garble1); garble2 -> md5.Update(hash, sizeof(hash)); md5.Update((u8 *)szSeed, strlen(szSeed)); md5.Final(garble2); garble3 -> md5.Update(garble1, sizeof(garble1)); md5.Final(garble3); any help on these errors?
Advertisement
It looks fairly straight forward. The compiler has no idea what the "garble" variables are.

Make sure that they are declared somewhere where the code you have is able to access them. So, make sure that they are declared in the same scope, are global, or are object members.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
heres the whole damn thing..i've even declared them and i get the SAME ERRORS

#include <iostream>
#include <md5.h>

using namespace CryptoPP;
//prototype function declaration
void input();


int garble1;
int garble2;
int garble3;

typedef unsigned char u8,u32;
//
int gs = 1;
char password[128];
char *p;

void input()
{
std::cout<<"Input Password: ";
std::cin>>password;
std::cin.get();
}

void main()
{
input();
}


void hashtest(char *p)
{
p = (char *)(&password[128]);
u8 hash[16] = {0};
// HashPassword(password, hash, sizeof(hash)); //for now just set some arbitrary values in 'hash'
char szSeed[(sizeof(u32) * 3) + 1] = {0};
itoa(gs, szSeed, 10); //GetSeed() is just a func that returns int, set it to whatever you like
MD5 md5;
//garble g;
u8 digest[MD5::DIGESTSIZE];
md5.Update(hash, sizeof(hash));
md5.Update((u8 *)szSeed, strlen(szSeed));
md5.Final(digest);// this is garble-2

garble1 -> md5.Update(hash, sizeof(hash)); md5.Final(garble1);
garble2 -> md5.Update(hash, sizeof(hash)); md5.Update((u8 *)szSeed, strlen(szSeed)); md5.Final(garble2);
garble3 -> md5.Update(garble1, sizeof(garble1)); md5.Final(garble3);
//Important thing, check if garble3==garble2

}
bump
oh yes the garbles are declared as ints now but i get these errors

.\main.cpp(38) : warning C4996: 'itoa' was declared deprecated
C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(820) : see declaration of 'itoa'
Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa. See online help for details.'
.\main.cpp(46) : error C2227: left of '->md5' must point to class/struct/union/generic type
type is 'int'
.\main.cpp(46) : error C2228: left of '.Update' must have class/struct/union
.\main.cpp(46) : error C2664: 'CryptoPP::HashTransformation::Final' : cannot convert parameter 1 from 'int' to 'byte *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
.\main.cpp(47) : error C2227: left of '->md5' must point to class/struct/union/generic type
type is 'int'
.\main.cpp(47) : error C2228: left of '.Update' must have class/struct/union
.\main.cpp(47) : error C2664: 'CryptoPP::HashTransformation::Final' : cannot convert parameter 1 from 'int' to 'byte *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
.\main.cpp(48) : error C2227: left of '->md5' must point to class/struct/union/generic type
type is 'int'
.\main.cpp(48) : error C2228: left of '.Update' must have class/struct/union
.\main.cpp(48) : error C2664: 'CryptoPP::HashTransformation::Final' : cannot convert parameter 1 from 'int' to 'byte *'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Quote:Original post by Dead_Zone
bump


Just for future references, you should wait at least 12 hours before a bump rather than 10 minutes, especially during this time (It's mostly bedtime for US people) [wink]

Anyways, for your code, you are making pointer calls, such as md5.Update(hash, sizeof(hash));, but you are using ints to do this. Towards the top of your program you have:
int garble1;int garble2;int garble3;

Now, at the bottom though, you have
garble1 -> md5.Update(hash, sizeof(hash)); md5.Final(garble1);garble2 -> md5.Update(hash, sizeof(hash)); md5.Update((u8 *)szSeed, strlen(szSeed)); md5.Final(garble2);garble3 -> md5.Update(garble1, sizeof(garble1)); md5.Final(garble3);

You are getting errors because 'int' in C++ is not a pointer, int* would be a pointer. BUT, 'int' is not a class either, so the class call you are trying to make is not correct. I do not have this md5 code so I'm not sure what it is supposed to be. I'd vecnture to say though, that you just need to take out the:
garble1 -> garble2 -> garble3 -> 

Code though, since that is the only part that does not make sense in all of that code. If md5.Update(hash, sizeof(hash)); returns an int, then you will need to make those:
garble1 =garble2 =garble3 =

If md5.Update(hash, sizeof(hash)); returns an int*, then you will need to make those:
garble1 = *md5.Update [...]garble2 = *md5.Update [...]garble3 = *md5.Update [...]

Replace the [...] with what goes there. Does that make sense? Go though and see if you can fix your errors according to this now. Good luck! [smile]

Oh and also, you can use the [source] your code here [/source] tags to post larger blocks of code in a cleaner format.
i changed the garbles from -> to = and here are the new errors

.\main.cpp(38) : warning C4996: 'itoa' was declared deprecated        C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(820) : see declaration of 'itoa'        Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa. See online help for details.'.\main.cpp(46) : error C2440: '=' : cannot convert from 'void' to 'int'        Expressions of type void cannot be converted to other types.\main.cpp(46) : error C2664: 'CryptoPP::HashTransformation::Final' : cannot convert parameter 1 from 'int' to 'byte *'        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast.\main.cpp(47) : error C2440: '=' : cannot convert from 'void' to 'int'        Expressions of type void cannot be converted to other types.\main.cpp(47) : error C2664: 'CryptoPP::HashTransformation::Final' : cannot convert parameter 1 from 'int' to 'byte *'        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast.\main.cpp(48) : error C2664: 'CryptoPP::IteratedHashBase<T,BASE>::Update' : cannot convert parameter 1 from 'int' to 'const byte *'        with        [            T=CryptoPP::word32,            BASE=CryptoPP::HashTransformation        ]        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast.\main.cpp(48) : error C2664: 'CryptoPP::HashTransformation::Final' : cannot convert parameter 1 from 'int' to 'byte *'        Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Don't be scared to post in our beginners forum.

My advice is to search the net for some other sample code that also uses "md5.h", and see what you can learn from the other code.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms
Quote:Original post by Dead_Zone
i changed the garbles from -> to = and here are the new errors

*** Source Snippet Removed ***


THen you will need to do what I mentioned as in the first of the three options, which is to take out the garbleX-> altogether. I'd also suggest trying to find reference code for this, since I know I haven't worked with this before. As for your last errors, the ones about not being able to convert the values correctly, you need to pass in "const byte *" instead of ints. Are you using this library? Try and find the docs on what you have to pass, I'm not sure.

Only guess would be to do something along the lines of:
md5.Update(hash, sizeof(hash)); md5.Final((const byte *)&garble1);md5.Update(hash, sizeof(hash)); md5.Update((u8 *)szSeed, strlen(szSeed)); md5.Final((const byte *)&garble2);md5.Update(garble1, sizeof(garble1)); md5.Final((const byte *)&garble3);

But it is, just a guess. Not sure if it's correct.
now im only hving these errors

.\main.cpp(38) : warning C4996: 'itoa' was declared deprecated
C:\Program Files\Microsoft Visual Studio 8\VC\include\stdlib.h(820) : see declaration of 'itoa'
Message: 'The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _itoa. See online help for details.'
.\main.cpp(46) : error C2227: left of '->md5' must point to class/struct/union/generic type
type is 'byte *'
.\main.cpp(46) : error C2228: left of '.Update' must have class/struct/union
.\main.cpp(47) : error C2227: left of '->md5' must point to class/struct/union/generic type
type is 'byte *'
.\main.cpp(47) : error C2228: left of '.Update' must have class/struct/union
.\main.cpp(48) : error C2227: left of '->md5' must point to class/struct/union/generic type
type is 'byte *'

again with garble 1-3

		garble1 ->  md5.Update(hash, sizeof(hash)); md5.Final(garble1);		garble2 ->  md5.Update(hash, sizeof(hash)); md5.Update((u8 *)szSeed, strlen(szSeed)); md5.Final(garble2);		garble3 ->  md5.Update(garble1, sizeof(garble1)); md5.Final((byte*)garble3);


This topic is closed to new replies.

Advertisement