|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--cryptix.security.MessageDigest
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.3 $
MessageDigest
Constructor Summary | |
protected |
MessageDigest(java.security.MessageDigest md)
Deprecated. Constructs a V2.2 message digest from a JCA message digest. |
Method Summary | |
void |
add(byte[] data)
Deprecated. Use update(data) instead. |
void |
add(byte[] data,
int offset,
int length)
Deprecated. Use update(data, offset, length) . |
void |
add(java.lang.String message)
Deprecated. Use update(cryptix.mime.LegacyString.toByteArray(message)) instead. |
void |
add(java.lang.String message,
int offset,
int length)
Deprecated. Use update(cryptix.mime.LegacyString.toByteArray(message,
offset, length)) instead. |
byte[] |
digest()
Deprecated. |
byte[] |
digest(byte[] data)
Deprecated. |
MessageHash |
digestAsHash()
Deprecated. Replace md.digestAsHash() with
MessageHash.fromDigest(md) . |
int |
hash_length()
Deprecated. Use getDigestLength() instead. |
static byte[] |
hash(byte[] data,
MessageDigest md)
Deprecated. Use md.digest(data) instead. |
static byte[] |
hash(java.lang.String message,
MessageDigest md)
Deprecated. |
int |
length()
Deprecated. Use getDigestLength() instead. |
java.lang.String |
name()
Deprecated. Use getAlgorithm() instead. |
void |
reset()
Deprecated. |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
protected MessageDigest(java.security.MessageDigest md)
md
- the java.security.MessageDigest object.Method Detail |
public final int hash_length()
getDigestLength()
instead.
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.
public final int length()
getDigestLength()
instead.
hash_length
.public final java.lang.String name()
getAlgorithm()
instead.
public final MessageHash digestAsHash()
md.digestAsHash()
with
MessageHash.fromDigest(md)
.
N.B. this method resets the digest.
MessageHash
public final void add(java.lang.String message, int offset, int length)
update(cryptix.mime.LegacyString.toByteArray(message,
offset, length))
instead.
\u00FF
gracefully.message
- the string to add.offset
- the start of the data string.length
- the length of the data string.NullPointerException
- if message == nullStringIndexOutOfBoundsException
- if offset or length are
out of rangepublic final void add(java.lang.String message)
update(cryptix.mime.LegacyString.toByteArray(message))
instead.
\u00FF
gracefully.message
- the string to add.NullPointerException
- if message == nullpublic final void add(byte[] data)
update(data)
instead.
data
- the data to be added.NullPointerException
- if data == nullpublic final void add(byte[] data, int offset, int length)
update(data, offset, length)
.
data
- the data to add.offset
- the start of the data to add.length
- the length of the data to add.NullPointerException
- if data == nullArrayIndexOutOfBoundsException
- if offset or length are
out of rangepublic final byte[] digest(byte[] data)
public final byte[] digest()
public final void reset()
public static byte[] hash(java.lang.String message, MessageDigest md)
\u00FF
gracefully.
E.g.:
import cryptix.security.MessageDigest;which should be replaced with:
byte[] key = MessageDigest.hash(passphrase, new SHA());
import java.security.MessageDigest; import cryptix.mime.LegacyString;or (better for new applications, but not completely compatible):
MessageDigest sha = MessageDigest.getInstance("SHA-1"); byte[] key = sha.digest(LegacyString.toByteArray(passphrase));
... byte[] key = sha.digest(passphrase.getBytes("UTF8"));
message
- the string to hash.md
- an instance of a message digest.public static byte[] hash(byte[] data, MessageDigest md)
md.digest(data)
instead.
E.g.:
import cryptix.security.MessageDigest;which should be replaced with
byte[] key = MessageDigest.hash(bytearray, new SHA());
import java.security.MessageDigest;
MessageDigest sha = MessageDigest.getInstance("SHA-1"); byte[] key = sha.digest(bytearray);
message
- the byte array to hashmd
- an instance of a message digest
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |