java.lang.Objectjava.security.MessageDigestSpi
public abstract class MessageDigestSpi
此类为 MessageDigest 类定义服务提供者接口 (SPI),MessageDigest 类提供信息摘要算法的功能,如 MD5 或 SHA。信息摘要是安全的单向哈希函数,它接收任意大小的数据,输出固定长度的哈希值。
希望提供特定信息摘要算法的密码服务提供者必须实现此类中的所有抽象方法。
实现可随意选择是否实现 Cloneable 接口。
MessageDigest
| 构造方法摘要 | |
|---|---|
MessageDigestSpi() |
|
| 方法摘要 | |
|---|---|
Object |
clone() 如果实现是可复制的,则返回一个副本。 |
protected abstract byte[] |
engineDigest() 通过执行诸如填充等之类的最终操作完成哈希计算。 |
protected int |
engineDigest(byte[] buf, int offset, int len) 通过执行诸如填充等之类的最终操作完成哈希计算。 |
protected int |
engineGetDigestLength() 返回以字节为单位的摘要长度。 |
protected abstract void |
engineReset() 为进一步使用重置摘要。 |
protected abstract void |
engineUpdate(byte input) 使用指定的字节更新摘要。 |
protected abstract void |
engineUpdate(byte[] input, int offset, int len) 使用指定的 byte 数组,在指定的偏移量处开始更新摘要。 |
protected void |
engineUpdate(ByteBuffer input) 使用指定的 ByteBuffer 更新摘要。 |
| 从类 java.lang.Object 继承的方法 |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 构造方法详细信息 |
|---|
public MessageDigestSpi()
| 方法详细信息 |
|---|
protected int engineGetDigestLength()
已将此具体方法添加到以前定义的这个抽象类中。(为了向后兼容性,它不能是抽象的)。
默认行为是返回 0。
提供者可以重写此方法来返回摘要长度。
protected abstract void engineUpdate(byte input)
input - 更新所使用的字节。
protected abstract void engineUpdate(byte[] input,
int offset,
int len)
input - 用来更新的 byte 数组。
offset - byte 数组中的偏移量,操作从此处开始。
len - 要使用的字节数,始于
offset。
protected void engineUpdate(ByteBuffer input)
input.position() 处的
input.remaining() 个字节更新摘要。一旦返回,该缓冲区的位置将等于它的界限;它的界限将不会更改。
input - ByteBuffer
protected abstract byte[] engineDigest()
engineDigest 被调用,引擎应该被重置(请参见
engineReset)。重置由引擎实现者负责。
protected int engineDigest(byte[] buf,
int offset,
int len)
throws DigestException
engineDigest 被调用,引擎应该被重置(请参见
engineReset)。重置由引擎实现者负责。 此方法应该是抽象的,但是为了二进制兼容性使其具体。有知识的 (Knowledgeable) 的提供者应该重写此方法。
buf - 存储摘要的输出缓冲区
offset - 输出缓冲区中的偏移量,操作从此处开始
len - 在 buf 中分配给摘要的字节数。此默认实现和 SUN 的提供者都不返回部分摘要。使用此参数仅仅是为了在 API 中保持一致性。如果此参数的值小于实际的摘要长度,该方法将抛出 DigestException。此参数的值如果大于等于实际的摘要长度,它会被忽略。
DigestException - 如果发生错误。
protected abstract void engineReset()
public Object clone() throws CloneNotSupportedException
CloneNotSupportedException - 如果对一个不支持
Cloneable 的实现调用此方法。
Cloneable