A method of generating a keystream for ciphering or deciphering a data stream, the method comprising: operating a nonlinear feedback shift register, NLFSR, including n register stages wherein the NLFSR is implemented in a Galois configuration, wherein at least one register stage (x 0,..., x 193) of the n register stages of the implemented NLFSR is representable by at least one register stage (x 0,..., x 193) of a linear feedback shift register, LFSR, wherein a first subset (x 0,..., x 193; x 218,..., x 231) of the n register stages of the implemented NLFSR is representable by a second subset (x 24,..., x 217; x 242,..., x 255) of a second NLFSR, wherein a number of register stages (x 217, x 255) receiving a nonlinear feedback in the second NLFSR is greater than one and less than a number of register stages (x 193, x 197, x 201, x 295, x 209, x 213, x 217, x 231, x 235, x 239, x 243, x 247, x 251, x 255) receiving a nonlinear feedback in the implemented NLFSR, and wherein the implemented NLFSR is transformable to the second NLFSR, which is an n -bit NLFSR, and which has only two nontrivial feedback functions of type f n − 1 x 0, x 1,..., x n − 1 = x 0 + f L x 1,..., x n − 1 + f N x 1,..., x n − 1 and f n − 1 − k x 0, x 1,..., x n − 1 = x n − k + f N x 1 − k,..., x n − 1 − k, wherein "-" is subtraction modulo n, wherein f L is a linear function and f N is a non-linear function; and outputting the keystream from a nonlinear output function, wherein an input of the nonlinear output function is coupled to at least two of the n register stages of the implemented NLFSR, and wherein the nonlinear output function includes linear terms and wherein the linear terms included in the nonlinear output function depend only on the first subset of the n register stages of the implemented NLFSR. operating a nonlinear feedback shift register, NLFSR, including n register stages wherein the NLFSR is implemented in a Galois configuration, wherein at least one register stage (x 0,..., x 193) of the n register stages of the implemented NLFSR is representable by at least one register stage (x 0,..., x 193) of a linear feedback shift register, LFSR, wherein a first subset (x 0,..., x 193; x 218,..., x 231) of the n register stages of the implemented NLFSR is representable by a second subset (x 24,..., x 217; x 242,..., x 255) of a second NLFSR, wherein a number of register stages (x 217, x 255) receiving a nonlinear feedback in the second NLFSR is greater than one and less than a number of register stages (x 193, x 197, x 201, x 295, x 209, x 213, x 217, x 231, x 235, x 239, x 243, x 247, x 251, x 255) receiving a nonlinear feedback in the implemented NLFSR, and wherein the implemented NLFSR is transformable to the second NLFSR, which is an n -bit NLFSR, and which has only two nontrivial feedback functions of type f n − 1 x 0, x 1,..., x n − 1 = x 0 + f L x 1,..., x n − 1 + f N x 1,..., x n − 1 and f n − 1 − k x 0, x 1,..., x n − 1 = x n − k + f N x 1 − k,..., x n − 1 − k, wherein "-" is subtraction modulo n, wherein f L is a linear function and f N is a non-linear function; and outputting the keystream from a nonlinear output function, wherein an input of the nonlinear output function is coupled to at least two of the n register stages of the implemented NLFSR, and wherein the nonlinear output function includes linear terms and wherein the linear terms included in the nonlinear output function depend only on the first subset of the n register stages of the implemented NLFSR.