Harshraj,Download the community commons module from the mendix market place you can use it there are already defined Java actions available.
Hi Harshraj,
The Mendix CommunityCommons module has this functionality see:
GenerateHMAC_SHA256_hash - Generates a base64 encoded asymmetric hash using the HMAC_SHA256 hash algorithm.
GenerateHMAC_SHA256 - Generates a hexadecimal encoded asymmetric hash using the HMAC_SHA256 hash algorithm.
The module will provide java actions that will encrypt your string.