KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > java > security > MessageDigest


1 package org.apache.java.security;
2
3 /*
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License")
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 /**
20  * This interface abstracts a message digest algorithm.
21  *
22  * <p><b>Note:</b> even if standard Java 1.1 APIs already provide a
23  * message digest implementation, this class is used on those Java
24  * runtime environments (like Kaffe) where the package
25  * <code>java.security</code> is highly improbable to be found.
26  *
27  * @author <a HREF="mailto:mazzocchi@mbox.systemy.it">Stefano Mazzocchi</a>
28  * @version $Id: MessageDigest.java,v 1.2.2.2 2004/05/20 03:03:54 seade Exp $
29  * @deprecated Use the java.security package.
30  */

31 public abstract class MessageDigest
32 {
33     /**
34      * Creates the algorithm and reset its state.
35      */

36     public MessageDigest()
37     {
38         this.reset();
39     }
40
41     /**
42      * Append another block to the message.
43      *
44      * @param block A byte[].
45      */

46     public void append(byte[] block)
47     {
48         this.append(block, 0, block.length);
49     }
50
51     /**
52      * Append another block of specified length to the message.
53      *
54      * @param block A byte[].
55      * @param length An int.
56      */

57     public void append(byte[] block,
58                        int length)
59     {
60         this.append(block, 0, length);
61     }
62
63     /**
64      * Append another block of specified length to the message
65      * starting at the given offset.
66      *
67      * @param block A byte[].
68      * @param offset An int.
69      * @param length An int.
70      */

71     public abstract void append(byte[] block,
72                                 int offset,
73                                 int length);
74
75     /**
76      * Appends a message block and return its message digest.
77      *
78      * @param block A byte[].
79      * @return A byte[].
80      */

81     public byte[] digest(byte[] block)
82     {
83         return this.digest(block, 0, block.length);
84     }
85
86     /**
87      * Appends a message block with specified length and return its
88      * message digest.
89      *
90      * @param block A byte[].
91      * @param length An int.
92      * @return A byte[].
93      */

94     public byte[] digest(byte[] block,
95                          int length)
96     {
97         return this.digest(block, 0, length);
98     }
99
100     /**
101      * Appends a message block with specified length starting from the
102      * given offset and return its message digest.
103      *
104      * @param block A byte[].
105      * @param offset An int.
106      * @param length An int.
107      * @return A byte[].
108      */

109     public abstract byte[] digest(byte[] block,
110                                   int offset,
111                                   int length);
112
113     /**
114      * Resets the state of the class. <b>Beware</b>: calling this
115      * method erases all data previously inserted.
116      */

117     public abstract void reset();
118 }
119
Popular Tags