Methods Summary |
---|
public java.lang.Object | clone()
if (this instanceof Cloneable) {
return super.clone();
} else {
throw new CloneNotSupportedException();
}
|
public int | digest(byte[] buf, int offset, int len)Computes and stores the final hash value for this {@link MessageDigest}.
After the digest is computed the receiver is reset.
if (buf == null ||
// offset < 0 || len < 0 ||
// checks for negative values are commented out intentionally
// see HARMONY-1148 for details
(long) offset + (long) len > buf.length) {
throw new IllegalArgumentException(Messages
.getString("security.05")); //$NON-NLS-1$
}
return engineDigest(buf, offset, len);
|
public byte[] | digest(byte[] input)Performs the final update and then computes and returns the final hash
value for this {@link MessageDigest}. After the digest is computed the
receiver is reset.
update(input);
return digest();
|
public byte[] | digest()Computes and returns the final hash value for this {@link MessageDigest}.
After the digest is computed the receiver is reset.
return engineDigest();
|
public final java.lang.String | getAlgorithm()Returns the name of the algorithm of this {@code MessageDigest}.
return algorithm;
|
public final int | getDigestLength()Returns the engine digest length in bytes. If the implementation does not
implement this function or is not an instance of {@code Cloneable},
{@code 0} is returned.
int l = engineGetDigestLength();
if (l != 0) {
return l;
}
if (!(this instanceof Cloneable)) {
return 0;
}
try {
MessageDigest md = (MessageDigest) clone();
return md.digest().length;
} catch (CloneNotSupportedException e) {
return 0;
}
|
public static java.security.MessageDigest | getInstance(java.lang.String algorithm)Returns a new instance of {@code MessageDigest} that utilizes the
specified algorithm.
if (algorithm == null) {
throw new NullPointerException(Messages.getString("security.01")); //$NON-NLS-1$
}
MessageDigest result;
synchronized (engine) {
engine.getInstance(algorithm, null);
if (engine.spi instanceof MessageDigest) {
result = (MessageDigest) engine.spi;
result.algorithm = algorithm;
result.provider = engine.provider;
return result;
} else {
result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
engine.provider, algorithm);
return result;
}
}
|
public static java.security.MessageDigest | getInstance(java.lang.String algorithm, java.lang.String provider)Returns a new instance of {@code MessageDigest} that utilizes the
specified algorithm from the specified provider.
if ((provider == null) || (provider.length() == 0)) {
throw new IllegalArgumentException(Messages.getString("security.02")); //$NON-NLS-1$
}
Provider p = Security.getProvider(provider);
if (p == null) {
throw new NoSuchProviderException(Messages.getString("security.03", provider)); //$NON-NLS-1$
}
return getInstance(algorithm, p);
|
public static java.security.MessageDigest | getInstance(java.lang.String algorithm, java.security.Provider provider)Returns a new instance of {@code MessageDigest} that utilizes the
specified algorithm from the specified provider.
if (provider == null) {
throw new IllegalArgumentException(Messages.getString("security.04")); //$NON-NLS-1$
}
if (algorithm == null) {
throw new NullPointerException(Messages.getString("security.01")); //$NON-NLS-1$
}
MessageDigest result;
synchronized (engine) {
engine.getInstance(algorithm, provider, null);
if (engine.spi instanceof MessageDigest) {
result = (MessageDigest) engine.spi;
result.algorithm = algorithm;
result.provider = provider;
return result;
} else {
result = new MessageDigestImpl((MessageDigestSpi) engine.spi,
provider, algorithm);
return result;
}
}
|
public final java.security.Provider | getProvider()Returns the provider associated with this {@code MessageDigest}.
return provider;
|
public static boolean | isEqual(byte[] digesta, byte[] digestb)Indicates whether to digest are equal by performing a simply
byte-per-byte compare of the two digests.
if (digesta.length != digestb.length) {
return false;
}
for (int i = 0; i < digesta.length; i++) {
if (digesta[i] != digestb[i]) {
return false;
}
}
return true;
|
public void | reset()Puts this {@code MessageDigest} back in an initial state, such that it is
ready to compute a one way hash value.
engineReset();
|
public java.lang.String | toString()Returns a string containing a concise, human-readable description of this
{@code MessageDigest} including the name of its algorithm.
return "MESSAGE DIGEST " + algorithm; //$NON-NLS-1$
|
public final void | update(java.nio.ByteBuffer input)Updates this {@code MessageDigest} using the given {@code input}.
engineUpdate(input);
|
public void | update(byte arg0)Updates this {@code MessageDigest} using the given {@code byte}.
engineUpdate(arg0);
|
public void | update(byte[] input, int offset, int len)Updates this {@code MessageDigest} using the given {@code byte[]}.
if (input == null ||
// offset < 0 || len < 0 ||
// checks for negative values are commented out intentionally
// see HARMONY-1120 for details
(long) offset + (long) len > input.length) {
throw new IllegalArgumentException(Messages
.getString("security.05")); //$NON-NLS-1$
}
engineUpdate(input, offset, len);
|
public void | update(byte[] input)Updates this {@code MessageDigest} using the given {@code byte[]}.
if (input == null) {
throw new NullPointerException(Messages.getString("security.06")); //$NON-NLS-1$
}
engineUpdate(input, 0, input.length);
|