Encryption and Decryption In Liferay


In Liferay , you can encrypt and decrypt  the senstive data. Liferay has provided easy way to encrypt the data.

Have a look at the Encryptor class , we find the methods to encrypt and decrypt the data.

Here is an example of encryption of data.


private String encrptData(ActionRequest actionRequest,String data) throws PortalException, SystemException, EncryptorException{

ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest. getAttribute(WebKeys.THEME_DISPLAY);

Company company = CompanyLocalServiceUtil.getCompany(themeDisplay.getCompanyId());

Key key = company.getKeyObj();

return Encryptor.encrypt(key, data);
}


The same string we can decrypt the following line as ,

                  Encryptor.decrypt(key, data);

So we may have an doubt which encryption algorithm liferay is using go to the portal.properties look at the following 2 properties.

 company.encryption.algorithm=DES
  company.encryption.key.size=56

Comments

  1. It looks like encryption is only supported in custom code. Is this true? Regular Liferay data, such as user information, cannot be encrypted?

    ReplyDelete

Post a Comment

Popular posts from this blog

Theme display in javascript

How to know which liferay version we are using

Opening portlet in popup