Try using $encode(text,m) and $decode(text,m), it seems to actually work better.