001    /**
002     * Copyright (c) 2000-2012 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.nio.ByteBuffer;
018    
019    /**
020     * @author Brian Wing Shun Chan
021     * @author Alexander Chow
022     * @author Connor McKay
023     */
024    public class DigesterUtil {
025    
026            public static String digest(ByteBuffer byteBuffer) {
027                    return getDigester().digest(byteBuffer);
028            }
029    
030            public static String digest(String text) {
031                    return getDigester().digest(text);
032            }
033    
034            public static String digest(String algorithm, ByteBuffer byteBuffer) {
035                    return getDigester().digest(algorithm, byteBuffer);
036            }
037    
038            public static String digest(String algorithm, String... text) {
039                    return getDigester().digest(algorithm, text);
040            }
041    
042            public static String digestBase64(ByteBuffer byteBuffer) {
043                    return getDigester().digestBase64(byteBuffer);
044            }
045    
046            public static String digestBase64(String text) {
047                    return getDigester().digestBase64(text);
048            }
049    
050            public static String digestBase64(String algorithm, ByteBuffer byteBuffer) {
051                    return getDigester().digestBase64(algorithm, byteBuffer);
052            }
053    
054            public static String digestBase64(String algorithm, String... text) {
055                    return getDigester().digestBase64(algorithm, text);
056            }
057    
058            public static String digestHex(ByteBuffer byteBuffer) {
059                    return getDigester().digestHex(byteBuffer);
060            }
061    
062            public static String digestHex(String text) {
063                    return getDigester().digestHex(text);
064            }
065    
066            public static String digestHex(String algorithm, ByteBuffer byteBuffer) {
067                    return getDigester().digestHex(algorithm, byteBuffer);
068            }
069    
070            public static String digestHex(String algorithm, String... text) {
071                    return getDigester().digestHex(algorithm, text);
072            }
073    
074            public static byte[] digestRaw(ByteBuffer byteBuffer) {
075                    return getDigester().digestRaw(byteBuffer);
076            }
077    
078            public static byte[] digestRaw(String text) {
079                    return getDigester().digestRaw(text);
080            }
081    
082            public static byte[] digestRaw(String algorithm, ByteBuffer byteBuffer) {
083                    return getDigester().digestRaw(algorithm, byteBuffer);
084            }
085    
086            public static byte[] digestRaw(String algorithm, String... text) {
087                    return getDigester().digestRaw(algorithm, text);
088            }
089    
090            public static Digester getDigester() {
091                    return _digester;
092            }
093    
094            public void setDigester(Digester digester) {
095                    _digester = digester;
096            }
097    
098            private static Digester _digester;
099    
100    }