If you want someone to be able to copy / paste ciphertext the ciphertext probably ought to be either base64 encoded or maybe hex encoded (ie. so "\0" is "00", etc)
Aside from that just replace all instances of encrypt with decrypt and vice versa and I'd expect you'd be good to go.