Example usage for com.liferay.portal.kernel.util DigesterUtil digestBase64

List of usage examples for com.liferay.portal.kernel.util DigesterUtil digestBase64

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util DigesterUtil digestBase64.

Prototype

public static String digestBase64(String algorithm, String... text) 

Source Link

Usage

From source file:com.liferay.sync.util.SyncUtil.java

License:Open Source License

public static String getChecksum(DLFileVersion dlFileVersion) throws PortalException {

    if (dlFileVersion.getSize() > PortletPropsValues.SYNC_FILE_CHECKSUM_THRESHOLD_SIZE) {

        return StringPool.BLANK;
    }//from  ww w. j a  v  a2s . c o  m

    return DigesterUtil.digestBase64(Digester.SHA_1, dlFileVersion.getContentStream(false));
}

From source file:com.liferay.sync.util.SyncUtil.java

License:Open Source License

public static String getChecksum(File file) throws PortalException {
    if (file.length() > PortletPropsValues.SYNC_FILE_CHECKSUM_THRESHOLD_SIZE) {

        return StringPool.BLANK;
    }// www.  j  a v a 2 s . com

    FileInputStream fileInputStream = null;

    try {
        fileInputStream = new FileInputStream(file);

        return DigesterUtil.digestBase64(Digester.SHA_1, fileInputStream);
    } catch (Exception e) {
        throw new PortalException(e);
    } finally {
        StreamUtil.cleanUp(fileInputStream);
    }
}