A method and apparatus for encoding or decoding a sequence of digital data