How about using something like <shamelessplug>this</shamelessplug>? ;-) It's very simple, but seems to do exactly what you need -- (en|de)cryption (after simple modification -- that implementation squashes all letters to lowercase) using alphabet permutation. The nice thing is that the result has the same length as before encryption.