encoding and decoding a string