1

This c code from a book on applied cryptography will not compile

int LFSR () {
static unsigned long ShiftRegister = 1;
/* Anything but 0. */
ShiftRegister = ((((ShiftRegister >> 31)
^ (ShiftRegister >> 6)
^ (ShiftRegister >> 4)
^ (ShiftRegister >> 2)
^ (ShiftRegister >> 1)
^ ShiftRegister))
& 0×00000001)
<< 31)
| (ShiftRegister >> 1) ;
return ShiftRegister & 0×00000001;
}

and there is no obvious mistake on it

chux - Reinstate Monica
  • 143,097
  • 13
  • 135
  • 256
  • 1
    Did you paste it from a web page or something like Microsoft word? https://stackoverflow.com/questions/22384338/stray-303-and-stray-215-in-program-why Look very carefully at the x that isn't an x... `0×00000001` – Retired Ninja May 05 '18 at 01:09
  • When you copy/paste code from an electronic source (web, PDF, or whatever) you have to be careful that the characters you see are the characters you get. In this case, FBergo is right: the 'x' isn't a letter 'x', it's a Unicode multiplication symbol. – lurker May 05 '18 at 01:15
  • Note: \327 == 215 = 0xD7 – chux - Reinstate Monica May 05 '18 at 01:15
  • Thank you everyone for the helpful feedback so there were two mistakes the Unicode as a mentioned in the thread and a missing parenthesis – Rafael Santana May 05 '18 at 02:57

1 Answers1

4

In the hexadecimal constants, those should be x (lower case letter X), not × (multiplication sign).

FBergo
  • 1,010
  • 8
  • 11