1 package org.apache.java.security;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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 264148 2005-08-29 14:21:04Z henning $
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 }