Encode and decode numbers according to an arbitrary string.