3 Replies - 345 Views - Last Post: 01 December 2014 - 03:37 PM Rate Topic: -----

#1 oscam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-September 14

Revers order of bytes unsigned char array :?

Posted 01 December 2014 - 03:22 PM

hi,

i need fastest method to revers order of bytes in my char array.

for example i have:

unsigned char buf[8];
// consider data stored in buf is 88 77 66 55 44 33 22 11
// how to reverse it to: 11 22 33 44 55 66 77 88 

// currently i can do it by equal assignment , i make another buf like:

unsigned char buf_ok[8];
 
        buf_ok[0]=buf[7];
	buf_ok[1]=buf[6];
	buf_ok[2]=buf[5];
	buf_ok[3]=buf[4];
	buf_ok[4]=buf[3];
	buf_ok[5]=buf[2];
	buf_ok[6]=buf[1];
	buf_ok[7]=buf[0];

// This does revers the bytes as i want but its very slow , i am looking for fast method ..





Is This A Good Question/Topic? 0
  • +

Replies To: Revers order of bytes unsigned char array :?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13545
  • View blog
  • Posts: 54,057
  • Joined: 12-June 08

Re: Revers order of bytes unsigned char array :?

Posted 01 December 2014 - 03:28 PM

09	        buf_ok[0]=buf[7];
10	    buf_ok[1]=buf[6];
11	    buf_ok[2]=buf[5];
12	    buf_ok[3]=buf[4];
13	    buf_ok[4]=buf[3];
14	    buf_ok[5]=buf[2];
15	    buf_ok[6]=buf[1];
16	    buf_ok[7]=buf[0];


Exactly how is this effective?


Let's say you have three options.

buf_ok[0]=5
buf_ok[1]=6
buf_ok[2]=7


Start:
[0]=5
[1]=6
[2]=7


buf_ok[0]=buf[2];
[0]=7
[1]=6
[2]=7


buf_ok[1]=buf[1];
[0]=7
[1]=6
[2]=7


buf_ok[2]=buf[0];
[0]=7
[1]=6
[2]=7

Was This Post Helpful? 0
  • +
  • -

#3 oscam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 15-September 14

Re: Revers order of bytes unsigned char array :?

Posted 01 December 2014 - 03:35 PM

hi modi123_1

The way you describe works but the method is slow ... i am writing a small brute force app this buf meant to hold each newly generated key , the way i revers is slow and it effect the program speed.


i want to reverse order of bytes in alternate and fast way ..

Regards
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13545
  • View blog
  • Posts: 54,057
  • Joined: 12-June 08

Re: Revers order of bytes unsigned char array :?

Posted 01 December 2014 - 03:37 PM

You totally wiffed on the issue that after you use your "reverse" program the "reversed" value is not right.

As it is, the larger issue is we will not help you with some brute force key cracker. I will ask you do not pursue it further here, and I am closing the topic.

If you have questions on the rules feel free to PM me.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1