模块 java.base

接口 SecretKey

所有父级接口:
Destroyable , Key , Serializable
所有已知的子接口:
PBEKey
所有已知的实现类:
EncryptionKey , KerberosKey , SecretKeySpec

public interface SecretKey extends Key , Destroyable
秘密(对称)密钥。此接口的目的是对所有密钥接口进行分组(并为其提供类型安全)。

此接口的提供者实现必须覆盖从 Object 继承的 equalshashCode 方法,以便根据其底层密钥材料而不是基于引用来比较密钥。实现应覆盖 Destroyable 接口中的默认 destroyisDestroyed 方法,以便销毁、清除敏感密钥信息,或者在此类信息不可变、未引用的情况下。最后,由于 SecretKeySerializable ,实现还应该覆盖 ObjectOutputStream.writeObject(java.lang.Object) 以防止已被销毁的密钥被序列化。

实现此接口的密钥返回字符串 RAW 作为它们的编码格式(参见 getFormat ),并返回原始密钥字节作为 getEncoded 方法调用的结果。 (getFormatgetEncoded 方法继承自 Key 父接口。)

自从:
1.4
参见:
  • 字段详细信息

    • serialVersionUID

      @Deprecated static final long serialVersionUID
      已弃用。
      接口中的 serialVersionUID 字段无效。不使用;没有替代品。
      自 J2SE 1.4 起设置为指示序列化兼容性的类指纹。
      参见: