replaced base64 implementation