Hello folks!
How do I insert in an
unsigned long * v; //supossed 4 bytes long, isn't it?
one to 4 chars?
But if it is
unsigned long *const v;
Thanks
Robert
Hello folks!
How do I insert in an
unsigned long * v; //supossed 4 bytes long, isn't it?
one to 4 chars?
But if it is
unsigned long *const v;
Thanks
Robert
huh?
what is *v?
Code:long val; char str[4]; memcpy(&val,str,4);Code:long val=0; char str[4]; for(int i=0; i<4; i++) { val |= ((long)str[i]) << (i*8); }
v is the name of the pointer, assumed to be an int.unsigned long * v;
You can use *ptr, *pointer, *your_preffered_name, etc.
I quoted from my listing.
Robert
ufhm I did the opposite!
Code:long val = 0xc0de; char str[4]; //there is no '\0' char... place it yourself if you want memcpy(str,&val,sizeof(val));
Code:long val = 0xc0de; char str[4]; for(int i=0; i<4;i++) str[i] = (char)(val >> (i*8));
by the way ...
why would you want this?
is for the :
Code:void code(long* v, long* k) { unsigned long y=v[0],z=v[1], sum=0,n=32 ; while (n-->0) { sum += DELTA ; y += (z<<4)+k[0] ^ z+sum ^ (z>>5)+k[1] ; z += (y<<4)+k[2] ^ y+sum ^ (y>>5)+k[3] ; } v[0]=y; v[1]=z; }
[QUOTE]Originally posted by borko_b
[B]Yes, thank you. This will do.Code:long val; char str[4]; memcpy(&val,str,4);
I am really crushed that I didn't see it. I need a vacation.
Robert
It's OK, I saw the idea.ufhm I did the opposite!
by the way ...
why would you want this?
is for the :
Code:void code(long* v, long* k) { ...
Is that so obvious?
Do I have to hide myself... to enjoy my cup of tea... :-(
Robert
No !
don't hide it!
I am a fan of TEA algorithm
currently i am making an OpenSource TEA file encoding tool
wich will be both Win32 and Linux compatible code
So i saw the long *v and made the connection!
Will you keep it low!?
[paranoid]Where do I hide... where do I go...[/paranoid]
Robert
[QUOTE]Originally posted by borko_b
[B]
No !
don't hide it!
... currently i am making an OpenSource TEA file ...
wich will be both Win32 and Linux compatible code
OK, ok. Keep me informed, please.
[paranoid]BTW, did you notice the anvelope that marks this tread? It has been sealed from the very beginning. What would this mean?[/paranoid]
[more paranoid]I didn't see another like this! Wouldn't you think of...[/more paranoid]
[paranoid]Where do I go... where do I hide...[/paranoid]
>>BTW, did you notice the anvelope that marks this tread? It has
>>been sealed from the very beginning. What would this mean?
i've got no idea...
oh is it a pointer aaah ok..
i know its a pointer i just didn't get your question.
?!? which part ?!? I got really confused about this!Originally posted by pode
oh is it a pointer aaah ok..
i know its a pointer i just didn't get your question.
this is for borko_b
You really did squeeze those chars in the unsig. long?
And did it work? :-)
Robert
>>You really did squeeze those chars in the unsig. long?
>>And did it work? :-)
No actually ... I don't use char s for the key..
i generate numbers like rand() from a string
and i pass them to the code() and decode()
and then modify them by a formula
after each code/decode so that the key is different
next time
what string? some user input?No actually ... I don't use char s for the key..
i generate numbers like rand() from a string
Are you able to save today and to read tomorrow this way?and i pass them to ...
and then modify them by a formula
after each code/decode so that the key is different
next time
being a simmetrical alg., aren't you exposing the user instead of protecting him?
Robert