This example shows how to URL encode a timestamp value in UTF-8 by calling urlEncode.
DateTime d = System.now(); String timestamp = ''+ d.year() + '-' + d.month() + '-' + d.day() + '\'T\'' + d.hour() + ':' + d.minute() + ':' + d.second() + '.' + d.millisecond() + '\'Z\''; System.debug(timestamp); String urlEncodedTimestamp = EncodingUtil.urlEncode(timestamp, 'UTF-8'); System.debug(urlEncodedTimestamp);
This next example shows how to use convertToHex to compute a client response for HTTP Digest Authentication (RFC2617).
@isTest private class SampleTest { static testmethod void testConvertToHex() { String myData = 'A Test String'; Blob hash = Crypto.generateDigest('SHA1',Blob.valueOf(myData)); String hexDigest = EncodingUtil.convertToHex(hash); System.debug(hexDigest); } }