Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
String key = 'hgdhdhhdjfh12ehsn';
String secret = 'DNf32sdsj747dhkjd8893jjjdjds7jjk';
//Generating current Unix timestamp (in seconds)
String getTime = string.valueOf(Datetime.Now().getTime()/1000);
String requestInput = key + secret + getTime;
Blob requestBlob = Blob.valueOf(requestInput);
Blob hash = Crypto.generateDigest('MD5', requestBlob);
//Need to convert into hex to generate the equivalent of md5(string) method of PHP.
String requestSignature = EncodingUtil.convertToHex(hash);
http h = new Http();
HttpRequest req = new HttpRequest();
//For security purpose, actual have been replaced with dashes
req.setEndpoint('https://www.---------/api/v1/-----/search?address=10313%2BSW%2');
req.setMethod('GET');
req.setHeader('Api-Key', key);
req.setHeader('Api-Signature', requestSignature);
HttpResponse res = h.send(req);
@matthewpoer

This comment has been minimized.

Copy link

matthewpoer commented Aug 22, 2018

Thank you!

//Need to convert into hex to generate the equivalent of md5(string) method of PHP.
String requestSignature = EncodingUtil.convertToHex(hash);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.