001: package org.apache.java.security;
002:
003: /*
004: * Copyright 2001-2005 The Apache Software Foundation.
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License")
007: * you may not use this file except in compliance with the License.
008: * 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, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * This interface abstracts a message digest algorithm.
021: *
022: * <p><b>Note:</b> even if standard Java 1.1 APIs already provide a
023: * message digest implementation, this class is used on those Java
024: * runtime environments (like Kaffe) where the package
025: * <code>java.security</code> is highly improbable to be found.
026: *
027: * @author <a href="mailto:mazzocchi@mbox.systemy.it">Stefano Mazzocchi</a>
028: * @version $Id: MessageDigest.java 264148 2005-08-29 14:21:04Z henning $
029: * @deprecated Use the java.security package.
030: */
031: public abstract class MessageDigest {
032: /**
033: * Creates the algorithm and reset its state.
034: */
035: public MessageDigest() {
036: this .reset();
037: }
038:
039: /**
040: * Append another block to the message.
041: *
042: * @param block A byte[].
043: */
044: public void append(byte[] block) {
045: this .append(block, 0, block.length);
046: }
047:
048: /**
049: * Append another block of specified length to the message.
050: *
051: * @param block A byte[].
052: * @param length An int.
053: */
054: public void append(byte[] block, int length) {
055: this .append(block, 0, length);
056: }
057:
058: /**
059: * Append another block of specified length to the message
060: * starting at the given offset.
061: *
062: * @param block A byte[].
063: * @param offset An int.
064: * @param length An int.
065: */
066: public abstract void append(byte[] block, int offset, int length);
067:
068: /**
069: * Appends a message block and return its message digest.
070: *
071: * @param block A byte[].
072: * @return A byte[].
073: */
074: public byte[] digest(byte[] block) {
075: return this .digest(block, 0, block.length);
076: }
077:
078: /**
079: * Appends a message block with specified length and return its
080: * message digest.
081: *
082: * @param block A byte[].
083: * @param length An int.
084: * @return A byte[].
085: */
086: public byte[] digest(byte[] block, int length) {
087: return this .digest(block, 0, length);
088: }
089:
090: /**
091: * Appends a message block with specified length starting from the
092: * given offset and return its message digest.
093: *
094: * @param block A byte[].
095: * @param offset An int.
096: * @param length An int.
097: * @return A byte[].
098: */
099: public abstract byte[] digest(byte[] block, int offset, int length);
100:
101: /**
102: * Resets the state of the class. <b>Beware</b>: calling this
103: * method erases all data previously inserted.
104: */
105: public abstract void reset();
106: }
|