first cut of wrapping encoding/decoding as an AngularJS service