9 Replies - 819 Views - Last Post: 11 September 2009 - 06:59 AM Rate Topic: -----

#1 qema_86  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 04-June 09

code character

Posted 10 September 2009 - 12:48 AM

 z -= (y << 4 ^ y >> 5) + y ^ sum + key[sum>>11 & 3];
		  sum -= delta;
		  y -= (z << 4 ^ z >> 5) + z ^ sum + key[sum&3];



here is the code that i took from the internet.. i just want to know what is the meaning of the [] in the code.
 key[sum&3]; 
is it array?

This post has been edited by qema_86: 10 September 2009 - 01:21 AM

Is This A Good Question/Topic? 0
  • +

Replies To: code character

#2 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: code character

Posted 10 September 2009 - 01:35 AM

It would appear to be that it is an array that has been created somewhere else but not instantiated.
btw,
Whered did you get this from? Are you sure that this is completely Java and not C# or J++?

I cannot say for sure as I have never seen some of those operators and without the rest of the code I wouldn't be able to tell you.

This post has been edited by Fuzzyness: 10 September 2009 - 01:37 AM

Was This Post Helpful? 0
  • +
  • -

#3 qema_86  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 04-June 09

Re: code character

Posted 10 September 2009 - 02:17 AM

actually it is from the cryptography algorithm..XTEA algorithm.. only that flow of feistel cipher i cant understand..

This post has been edited by qema_86: 10 September 2009 - 02:21 AM

Was This Post Helpful? 0
  • +
  • -

#4 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: code character

Posted 10 September 2009 - 02:18 AM

Which is why I have never seen it before :)

haven't covered that in class yet and too lazy to teach myself x . x
Was This Post Helpful? 0
  • +
  • -

#5 qema_86  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 04-June 09

Re: code character

Posted 10 September 2009 - 02:22 AM

XTEA algorithm..
Was This Post Helpful? 0
  • +
  • -

#6 qema_86  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 04-June 09

Re: code character

Posted 10 September 2009 - 12:48 PM

i had found the diagram that show the algorithm..
http://commons.wikim...jpg#filehistory
Was This Post Helpful? 0
  • +
  • -

#7 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: code character

Posted 10 September 2009 - 01:11 PM

View PostFuzzyness, on 10 Sep, 2009 - 02:35 AM, said:

I cannot say for sure as I have never seen some of those operators and without the rest of the code I wouldn't be able to tell you.


The operators are bit-wise operators.

<< - shift bits to the left
>> - shift bits to the right
^ - exclusive or
& - logical and.
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: code character

Posted 10 September 2009 - 08:05 PM

View Postqema_86, on 9 Sep, 2009 - 11:48 PM, said:

 z -= (y << 4 ^ y >> 5) + y ^ sum + key[sum>>11 & 3];
		  sum -= delta;
		  y -= (z << 4 ^ z >> 5) + z ^ sum + key[sum&3];



here is the code that i took from the internet.. i just want to know what is the meaning of the [] in the code.
 key[sum&3]; 
is it array?

For the original question Yes it is an array
they should have taken more meaningfull variable names than x,y,z

so:

z = z minus
y left shifted 4 bits (basically multiplied by 16) Xored with y shifted 5 bits to the right (basically divided by 32)
plus y Xorded with sum
plus key[index = sum shifted 11 bits left & 3 so the righmost 2 bits of sum shifted
....
Was This Post Helpful? 0
  • +
  • -

#9 syfran  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 83
  • View blog
  • Posts: 1,103
  • Joined: 12-July 09

Re: code character

Posted 10 September 2009 - 11:06 PM

View PostFuzzyness, on 10 Sep, 2009 - 12:35 AM, said:

I cannot say for sure as I have never seen some of those operators and without the rest of the code I wouldn't be able to tell you.


O.o I am going to write a tutorial on them sooner or later. Now knowing it isn't as common as I thought I may starting shooting for the sooner. :P

View Postpbl, on 10 Sep, 2009 - 07:05 PM, said:

they should have taken more meaningfull variable names than x,y,z


Something about those cryptography people.
Was This Post Helpful? 0
  • +
  • -

#10 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: code character

Posted 11 September 2009 - 06:59 AM

View Postsyfran, on 11 Sep, 2009 - 12:06 AM, said:

Something about those cryptography people.


Make it hard to define what variable means what. All the better encryption. :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1