Encode and decode as String