The forward transformations are straightforward. The trickiest reverse implementation is the rotation based on the index of the letter.