001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing,
013     * software distributed under the License is distributed on an
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     * KIND, either express or implied.  See the License for the
016     * specific language governing permissions and limitations
017     * under the License.
018     */
019    package org.apache.shiro.crypto.hash;
020    
021    /**
022     * A Cryptographic {@code Hash} represents a one-way conversion algorithm that transforms an input source to an
023     * underlying byte array.
024     *
025     * @author Les Hazlewood
026     * @see AbstractHash
027     * @see Md2Hash
028     * @see Md5Hash
029     * @see Sha1Hash
030     * @see Sha256Hash
031     * @see Sha384Hash
032     * @see Sha512Hash
033     * @since 0.9
034     */
035    public interface Hash {
036    
037        /**
038         * Returns this Hash's byte array, that is, the hashed value of the original input source.
039         *
040         * @return this Hash's byte array, that is, the hashed value of the original input source.
041         * @see #toHex
042         * @see #toBase64
043         */
044        byte[] getBytes();
045    
046        /**
047         * Returns a Hex encoding of this Hash's {@link #getBytes byte array}.
048         *
049         * @return a Hex encoding of this Hash's {@link #getBytes byte array}.
050         */
051        String toHex();
052    
053        /**
054         * Returns a Base64 encoding of this Hash's {@link #getBytes byte array}.
055         *
056         * @return a Base64 encoding of this Hash's {@link #getBytes byte array}.
057         */
058        String toBase64();
059    }