Brainache
Member
|
RE: Convert string to char*
Here's a couple functions I use for send Esenthel Str using Raknet
I dont like the packString iteration.. but it does work...
void packString(Str test, RakNet::BitStream *output)
{
char buffer[4096];
int i;
for (i=0;i<test.length(); i++)
{
buffer[i] = test[i];
}
buffer[i] = '\0';
stringCompressor->EncodeString(buffer, 256, output);
}
Str unpackString(RakNet::BitStream *input)
{
char buffer[256];
stringCompressor->DecodeString(buffer, 256, input);
//cout << buffer;
Str test = Str(buffer);
return test;
}
|
|
02-10-2010 04:11 PM |
|
Dynad
Member
|
RE: Convert string to char*
Yea this will work as well indeed
There is always evil somewhere, you just have to look for it properly.
|
|
02-10-2010 05:10 PM |
|
trouble
Member
|
RE: Convert string to char*
I think I don't understand this correctly.
What I did was saving Str type in to string type.
I having problems with doing the opposite.
Str test = (CChar8*)mystring or Str test = (char*)mystring doesn't want to work.
What am I doing wrong?
|
|
02-06-2012 01:56 AM |
|
Zervox
Member
|
RE: Convert string to char*
isn't it supposed to be Str8 test in this case?
|
|
02-06-2012 02:57 AM |
|
trouble
Member
|
RE: Convert string to char*
yes, my current Str was converted to Str8 by
string mystring;
mystring=(Str8)test;
but now nothing seems to work ( cant do the opposite ). I m trying to do:
test=mystring;
I need to convert mystring in to Str type.
Code:
std::string pass=(Str8)password;
MD5 hashedPass(pass);
password= ??
(This post was last modified: 02-06-2012 03:46 PM by trouble.)
|
|
02-06-2012 03:43 PM |
|
Zervox
Member
|
RE: Convert string to char*
Str8 conv=(Str8)password;
std::string pass=conv();
?
|
|
02-06-2012 05:16 PM |
|
trouble
Member
|
RE: Convert string to char*
no not really, I got it like this now. Everything compiles
Code:
std::string pass=(Str8)(password)();
(Str8)password()=&md5(pass);
when I do that, operator= fails and password is beeing input one not the hash. How can I solve this?
|
|
02-06-2012 10:19 PM |
|
Dynad
Member
|
RE: Convert string to char*
assign the md5 return to a new value? and use that?
There is always evil somewhere, you just have to look for it properly.
|
|
02-06-2012 10:24 PM |
|
trouble
Member
|
RE: Convert string to char*
same result using
Code:
std::string pass=(Str8)(password)();
std::string res=md5(pass);
(Str8)password()=&res;
md5 algorithm is from here:
http://www.zedwood.com/article/121/cpp-md5-function
SOLVED
I don't like solution but it works.
Code:
std::string pass=(Str8)(password)();
std::string x=md5(pass);
password=S;
password+=&x[0];
(This post was last modified: 02-07-2012 02:00 AM by trouble.)
|
|
02-06-2012 10:33 PM |
|