Re: Fast DES IP implementation
From: Paul Rubin (//phr.cx_at_NOSPAM.invalid)
Date: 12/09/04
- Next message: Francois Grieu: "[OT] Linked list fixup [was: Fast DES IP]"
- Previous message: Mok-Kong Shen: "Re: Randomness from data"
- In reply to: Arnaud Carré: "Re: Fast DES IP implementation"
- Next in thread: Arnaud Carré: "Re: Fast DES IP implementation"
- Reply: Arnaud Carré: "Re: Fast DES IP implementation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: 09 Dec 2004 02:49:47 -0800
"Arnaud Carré" <arnaud.carreNOSPAM@freesurf.fr> writes:
> Hey that's not "trick", that's logic ! Do you think the "xor trick" does not
> work when i == j ?? :-)
>
> Try yourself !!
>
> int i = 0x12345678;
> int j = i;
>
> i ^= j;
> j ^= i;
> i ^= j;
>
> i and j are swapped, whatever the content !! (even if they are equal or
> course !)
You're not understanding the problem. You don't want to swap i and j.
You want to swap a[i] and a[j]. Try like this:
int a[2] = {0x12345678, 1};
int i = 0;
int j = 1;
a[i] ^= a[j];
a[j] ^= a[i];
a[i] ^= a[j];
This works ok, since i != j. Now try with i=j :-(.
- Next message: Francois Grieu: "[OT] Linked list fixup [was: Fast DES IP]"
- Previous message: Mok-Kong Shen: "Re: Randomness from data"
- In reply to: Arnaud Carré: "Re: Fast DES IP implementation"
- Next in thread: Arnaud Carré: "Re: Fast DES IP implementation"
- Reply: Arnaud Carré: "Re: Fast DES IP implementation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]