All Packages Class Hierarchy This Package Previous Next Index
Class cryptix.security.MessageDigest
java.lang.Object
|
+----cryptix.security.MessageDigest
- public abstract class MessageDigest
- extends Object
Note: MessageDigest is deprecated.
This is the abstract superclass for message digests that support the
Cryptix V2.2 API. New code should use java.security.MessageDigest
in preference.
Note: the following methods are no longer supported (starting from Cryptix
2.2.2), because they either have no JCE equivalent, or were part of the
implementation of MessageDigest and should not have been public.
-
public long bitcount();
-
public int data_length();
-
public byte[] buf();
-
public int buf_off();
Copyright © 1995-1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.2 $
- Author:
- Systemics Ltd, David Hopwood
- See Also:
- MessageDigest
-
MessageDigest(MessageDigest)
- Constructs a V2.2 message digest from a JCA message digest.
-
add(byte[])
- Adds a byte array to the digest.
Deprecated.
-
add(byte[], int, int)
- Adds a section of a byte array to the digest.
Deprecated.
-
add(String)
- Adds the low bytes of a string to the digest.
Deprecated.
-
add(String, int, int)
- Adds the low bytes of a string to the digest.
Deprecated.
-
digest()
-
-
digest(byte[])
-
-
digestAsHash()
- Obtains a MessageHash object for this digest.
Deprecated.
-
hash(byte[], MessageDigest)
- A convenience function for hashing a byte array.
Deprecated.
-
hash(String, MessageDigest)
- A convenience function for hashing the low bytes of a string.
Deprecated.
-
hash_length()
- Returns the digest length in bytes.
Deprecated.
-
length()
- Identical to
hash_length
.
Deprecated.
-
name()
- Returns the message digest name.
Deprecated.
-
reset()
-
MessageDigest
protected MessageDigest(MessageDigest md)
- Constructs a V2.2 message digest from a JCA message digest.
- Parameters:
- md - the java.security.MessageDigest object.
hash_length
public final int hash_length()
- Note: hash_length() is deprecated.
Use
getDigestLength()
instead.
- Returns the digest length in bytes.
The JCA equivalent to this method,
java.security.MessageDigest.getDigestLength
, is only supported
when the IJCE version of the java.security.MessageDigest class
is first on the classpath. getDigestLength
will also be
supported by Java 1.2.
length
public final int length()
- Note: length() is deprecated.
Use
getDigestLength()
instead.
- Identical to
hash_length
.
name
public final String name()
- Note: name() is deprecated.
Use
getAlgorithm()
instead.
- Returns the message digest name.
digestAsHash
public final MessageHash digestAsHash()
- Note: digestAsHash() is deprecated.
Replace
md.digestAsHash()
with
MessageHash.fromDigest(md)
.
- Obtains a MessageHash object for this digest.
N.B. this method resets the digest.
- Returns:
- the MessageHash of all the data added.
- See Also:
- MessageHash
add
public final void add(String message,
int offset,
int length)
- Note: add() is deprecated.
Use
update(cryptix.mime.LegacyString.toByteArray(message,
offset, length))
instead.
- Adds the low bytes of a string to the digest. This should not be used
when internationalization is a concern, since it does not handle
Unicode characters above
\u00FF
gracefully.
- Parameters:
- message - the string to add.
- offset - the start of the data string.
- length - the length of the data string.
- Throws: NullPointerException
- if message == null
- Throws: StringIndexOutOfBoundsException
- if offset or length are
out of range
add
public final void add(String message)
- Note: add() is deprecated.
Use
update(cryptix.mime.LegacyString.toByteArray(message))
instead.
- Adds the low bytes of a string to the digest. This should not be used
when internationalization is a concern, since it does not handle
Unicode characters above
\u00FF
gracefully.
- Parameters:
- message - the string to add.
- Throws: NullPointerException
- if message == null
add
public final void add(byte data[])
- Note: add() is deprecated.
Use
update(data)
instead.
- Adds a byte array to the digest.
- Parameters:
- data - the data to be added.
- Throws: NullPointerException
- if data == null
add
public final void add(byte data[],
int offset,
int length)
- Note: add() is deprecated.
Use
update(data, offset, length)
.
- Adds a section of a byte array to the digest.
- Parameters:
- data - the data to add.
- offset - the start of the data to add.
- length - the length of the data to add.
- Throws: NullPointerException
- if data == null
- Throws: ArrayIndexOutOfBoundsException
- if offset or length are
out of range
digest
public final byte[] digest(byte data[])
digest
public final byte[] digest()
reset
public final void reset()
hash
public static byte[] hash(String message,
MessageDigest md)
- Note: hash() is deprecated.
- A convenience function for hashing the low bytes of a string. This should
not be used when internationalization is a concern, since it does not
handle Unicode characters above
\u00FF
gracefully.
E.g.:
import cryptix.security.MessageDigest;
byte[] key = MessageDigest.hash(passphrase, new SHA());
which should be replaced with:
import java.security.MessageDigest;
import cryptix.mime.LegacyString;
MessageDigest sha = MessageDigest.getInstance("SHA-1");
byte[] key = sha.digest(LegacyString.toByteArray(passphrase));
or (better for new applications, but not completely compatible):
...
byte[] key = sha.digest(passphrase.getBytes("UTF8"));
- Parameters:
- message - the string to hash.
- md - an instance of a message digest.
hash
public static byte[] hash(byte data[],
MessageDigest md)
- Note: hash() is deprecated.
Use
md.digest(data)
instead.
- A convenience function for hashing a byte array.
E.g.:
import cryptix.security.MessageDigest;
byte[] key = MessageDigest.hash(bytearray, new SHA());
which should be replaced with
import java.security.MessageDigest;
MessageDigest sha = MessageDigest.getInstance("SHA-1");
byte[] key = sha.digest(bytearray);
- Parameters:
- message - the byte array to hash
- md - an instance of a message digest
All Packages Class Hierarchy This Package Previous Next Index