use base64 encoding and make algo configurable.