Wrap encode functon with cred encrypt function, with tests.