001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.util;
016    
017    import java.io.InputStream;
018    
019    import java.nio.ByteBuffer;
020    
021    /**
022     * @author Brian Wing Shun Chan
023     * @author Alexander Chow
024     * @author Connor McKay
025     */
026    public interface Digester {
027    
028            public static final String DEFAULT_ALGORITHM = "SHA";
029    
030            public static final String ENCODING = StringPool.UTF8;
031    
032            public static final String MD5 = "MD5";
033    
034            public static final String SHA = "SHA";
035    
036            public static final String SHA_1 = "SHA-1";
037    
038            public String digest(ByteBuffer byteBuffer);
039    
040            public String digest(InputStream inputStream);
041    
042            public String digest(String text);
043    
044            public String digest(String algorithm, ByteBuffer byteBuffer);
045    
046            public String digest(String algorithm, InputStream inputStream);
047    
048            public String digest(String algorithm, String... text);
049    
050            public String digestBase64(ByteBuffer byteBuffer);
051    
052            public String digestBase64(InputStream inputStream);
053    
054            public String digestBase64(String text);
055    
056            public String digestBase64(String algorithm, ByteBuffer byteBuffer);
057    
058            public String digestBase64(String algorithm, InputStream inputStream);
059    
060            public String digestBase64(String algorithm, String... text);
061    
062            public String digestHex(ByteBuffer byteBuffer);
063    
064            public String digestHex(InputStream inputStream);
065    
066            public String digestHex(String text);
067    
068            public String digestHex(String algorithm, ByteBuffer byteBuffer);
069    
070            public String digestHex(String algorithm, InputStream inputStream);
071    
072            public String digestHex(String algorithm, String... text);
073    
074            public byte[] digestRaw(ByteBuffer byteBuffer);
075    
076            public byte[] digestRaw(String text);
077    
078            public byte[] digestRaw(String algorithm, ByteBuffer byteBuffer);
079    
080            public byte[] digestRaw(String algorithm, InputStream inputStream);
081    
082            public byte[] digestRaw(String algorithm, String... text);
083    
084    }