MessageDigest md = MessageDigest(getInstance{ algorithm })
should be
MessageDigest md = MessageDigest.getInstance(algorithm)
The corrected figure looks like this:
p. 222: The last line of Example 10-1 should construct the BigInteger
for result
,
not data
. That is.
System.out.println(new BigInteger(result));
% java URLDigest http://www.oreilly.com -24 86 -50 -110 47 -95 12 -95 -36 38 -110 -10 -53 -33 -80 -101 -33 74 -76 41 -135079919537261070114700613868500318745039031255p. 224, 225: The description of the third
digest()
method on pp. 224-225 is incorrect. Replace that section with the following:
p. 227: In the output at the top of the page,Finishing the Digest
In general, digest algorithms cannot finish the calculation and return the digest until the last byte is received. When you are ready to finish the calculation and receive the digest, you invoke one of three overloaded
digest()
methods:public byte[] digest() public byte[] digest(byte[] input) public int digest(byte[] output, int offset, int length) throws DigestException
The first
digest()
method simply returns the digest as an array of bytes based on the data that was already passed in throughupdate()
. For example,
byte[] result = sha.digest();
The second
digest()
method receives one last chunk of data in theinput
array, then returns the digest. The thirddigest()
method calculates the digest and places it in the arrayoutput
beginning atoffset
and continuing for at mostlength
bytes, then returns the number of bytes in the digest. If there are more thanlength
bytes in the digest aDigestException
is thrown. After you've calleddigest()
, theMessageDigest
object is reset so it can be reused to calculate a new digest.
http://metalab.uakom.sk/javafaq/ is up to date
should be
http://sunsite.uakom.sk/javafaq/ is up to date
. (Blame it on a
an overly aggressive search and replace.)p. 228: At the top of the page replace the first paragraph and line of code with this (which is accurate as of the release version of the JDK 1.2)
This returns a string in the form "algorithm Message Digest from provider, <initialized>" or "algorithm Message Digest from provider, <in progress>". For example,
SHA Message Digest from SUN, <initialized>
p. 254: Figure 10-3 has the wrong capitalization of GZipOutputStream
.
It should be GZIPOutputStream
.
p. 255: In the second paragraph, change "Like all filter stream constructors, this constructor also takes another input stream as an argument:" to "Like all filter input stream constructors, this constructor takes another input stream as an argument:"
p. 257: The first class declaration on the page says CipherInputStream
instead of
CipherOutputStream
. The declaration should be
public class CipherOutputStream extends FilterOutputStream
In the following paragraph, change "Like all filter stream constructors, this constructor also takes another input stream as an argument:" to "Like all filter output stream constructors, this constructor takes another output stream as an argument:"
p. 263: In the third code line on this page, it's helpful to add a test that the password is not the empty string. It doesn't matter for this application alone, but it will later. So change
if (password != null) {
to
if (password != null && !password.equals("")) {