Skip to content

Instantly share code, notes, and snippets.

@JitendraZaa
Created May 4, 2020 23:09
Show Gist options
  • Save JitendraZaa/44763fef2896e631a599d33cad33c652 to your computer and use it in GitHub Desktop.
Save JitendraZaa/44763fef2896e631a599d33cad33c652 to your computer and use it in GitHub Desktop.
Gravatar – Reusable Lightning Web Component Apex Controller
/**
* @Author Jitendra Zaa
* @Date 1 May 2020
* @Desc Server Side class for Gravatar LWC component to compute Md5 equivalent of email address
*/
public with sharing class GravatarController {
@AuraEnabled(cacheable=true)
public static String getMD5Hash(String email){
if(String.isEmpty(email)){
email = '[email protected]';
}
Blob emailBlob = Blob.valueOf(email);
Blob hash = Crypto.generateDigest('MD5', emailBlob);
return EncodingUtil.convertToHex(hash);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment