pgm 22.14, encrypt a character stream