java.security
Class MessageDigest
Message digests are secure one-way hash functions that take arbitrary-sized
data and output a fixed-length hash value.
MessageDigest(String algorithm) - Constructs a new instance of
MessageDigest representing the
specified algorithm.
|
Object | clone() - Returns a clone of this instance if cloning is supported.
|
byte[] | digest() - Computes the final digest of the stored data.
|
byte[] | digest(byte[] input) - Computes a final update using the input array of bytes, then computes a
final digest and returns it.
|
int | digest(byte[] buf, int offset, int len) - Computes the final digest of the stored bytes and returns the result.
|
String | getAlgorithm() - Returns the name of message digest algorithm.
|
int | getDigestLength() - Returns the length of the message digest.
|
static MessageDigest | getInstance(String algorithm) - Returns a new instance of
MessageDigest representing the
specified algorithm.
|
static MessageDigest | getInstance(String algorithm, String provider) - Returns a new instance of
MessageDigest representing the
specified algorithm from a named provider.
|
static MessageDigest | getInstance(String algorithm, Provider provider) - Returns a new instance of
MessageDigest representing the
specified algorithm from a designated Provider .
|
Provider | getProvider() - Returns the
Provider of this instance.
|
static boolean | isEqual(byte[] digesta, byte[] digestb) - Does a simple byte comparison of the two digests.
|
void | reset() - Resets this instance.
|
String | toString() - Returns a string representation of this instance.
|
void | update(byte input) - Updates the digest with the byte.
|
void | update(byte[] input) - Updates the digest with the bytes of an array.
|
void | update(byte[] input, int offset, int len) - Updates the digest with the bytes from the array starting from the
specified offset and using the specified length of bytes.
|
void | update(ByteBuffer input) - Updates the digest with the remaining bytes of a buffer.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
MessageDigest
protected MessageDigest(String algorithm)
Constructs a new instance of MessageDigest
representing the
specified algorithm.
algorithm
- the name of the digest algorithm to use.
digest
public byte[] digest()
Computes the final digest of the stored data.
- a byte array representing the message digest.
digest
public byte[] digest(byte[] input)
Computes a final update using the input array of bytes, then computes a
final digest and returns it. It calls
update(byte[])
and then
digest(byte[])
.
input
- an array of bytes to perform final update with.
- a byte array representing the message digest.
digest
public int digest(byte[] buf,
int offset,
int len)
throws DigestException
Computes the final digest of the stored bytes and returns the result.
buf
- an array of bytes to store the result in.offset
- an offset to start storing the result at.len
- the length of the buffer.
- Returns the length of the buffer.
getAlgorithm
public final String getAlgorithm()
Returns the name of message digest algorithm.
- the name of message digest algorithm.
getDigestLength
public final int getDigestLength()
Returns the length of the message digest. The default is zero which means
that the concrete implementation does not implement this method.
- length of the message digest.
getInstance
public static MessageDigest getInstance(String algorithm)
throws NoSuchAlgorithmException
Returns a new instance of MessageDigest
representing the
specified algorithm.
algorithm
- the name of the digest algorithm to use.
- a new instance representing the desired algorithm.
isEqual
public static boolean isEqual(byte[] digesta,
byte[] digestb)
Does a simple byte comparison of the two digests.
digesta
- first digest to compare.digestb
- second digest to compare.
true
if both are equal, false
otherwise.
reset
public void reset()
Resets this instance.
toString
public String toString()
Returns a string representation of this instance.
- toString in interface Object
- a string representation of this instance.
update
public void update(byte input)
Updates the digest with the byte.
input
- byte to update the digest with.
update
public void update(byte[] input)
Updates the digest with the bytes of an array.
input
- bytes to update the digest with.
update
public void update(byte[] input,
int offset,
int len)
Updates the digest with the bytes from the array starting from the
specified offset and using the specified length of bytes.
input
- bytes to update the digest with.offset
- the offset to start at.len
- length of the data to update with.
update
public void update(ByteBuffer input)
Updates the digest with the remaining bytes of a buffer.
input
- The input byte buffer.
MessageDigest.java --- The message digest interface.
Copyright (C) 1999, 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.