I assume you know all about ASCII, and have an ASCII chart.

So, you need 3 arrays:
OrigString[]
EncString[]
Convert[]

The original character becomes a pointer (or index value) for the convert array.

From your example:
a = 97
b = 98
t = 116

And we know,
Convert[97] = 98 (97 points to 98)
Convert[98] = 116 (98 points to 116)
... You fill-in the rest.

In general,
EncString[n] = Convert[ OrigString[n] ]

been around for well over a thousand years.
Yeah, but they've only been doing it in C++ for about 100 years!