public class SecretKeySpec extends Object implements KeySpec, SecretKey
它可以用来从一个字节数组构造SecretKey,不必经历(供应商的)SecretKeyFactory。
此类只用于原始密钥,可以表示为一个字节数组,并没有与它们相关联的关键参数,例如,辅或三重密钥密钥。
SecretKey,
SecretKeyFactory,
Serialized Form
| Constructor and Description |
|---|
SecretKeySpec(byte[] key, int offset, int len, String algorithm)
构建一个密钥从给定的字节数组,使用
key第一
len字节,从
offset包容。
|
SecretKeySpec(byte[] key, String algorithm)
从给定的字节数组构造一个密钥密钥。
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj)
指定对象和该对象之间的相等性的测试。
|
String |
getAlgorithm()
返回与此密钥关联的算法的名称。
|
byte[] |
getEncoded()
返回此密钥密钥的密钥材料。
|
String |
getFormat()
返回此密钥的编码格式的名称。
|
int |
hashCode()
计算对象的哈希代码值。
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitdestroy, isDestroyedpublic SecretKeySpec(byte[] key,
String algorithm)
此构造函数不检查给定字节是否确实指定指定算法的密钥密钥。例如,如果算法是DES,这个构造函数不检查key是8字节长,也不检查弱或半弱密钥。为了让这些支票要执行,一个算法的具体重点规范类(在这种情况下:DESKeySpec)应使用。
key -秘密的关键材料。数组的内容被复制以防止后续的修改。
algorithm -密钥算法的名称必须与给定材料相关的关键。见附录A中的
Java Cryptography Architecture Reference Guide有关标准算法名称信息。
IllegalArgumentException -如果
algorithm是null或
key是null或空。
public SecretKeySpec(byte[] key,
int offset,
int len,
String algorithm)
key第一
len字节,从
offset包容。
构成密钥字节之间key[offset]和key[offset+len-1]包容。
此构造函数不检查给定字节是否确实指定指定算法的密钥密钥。例如,如果算法是DES,这个构造函数不检查key是8字节长,也不检查弱或半弱密钥。为了让这些支票要执行,一个算法的具体重点规范类(在这种情况下:DESKeySpec)必须使用。
key -秘密的关键材料。在
offset包含数组开始的第一
len字节复制到防止后续的修改。
offset -
key其中关键材料开始的偏移量。
len -关键材料的长度。
algorithm -密钥算法的名称必须与给定材料相关的关键。见附录A中的
Java Cryptography Architecture Reference Guide有关标准算法名称信息。
IllegalArgumentException -如果
algorithm是null或
key是空的,空的,或过短,即
key.length-offset<len。
ArrayIndexOutOfBoundsException -如果
offset或
len指数字节外
key扔。
public String getAlgorithm()
getAlgorithm 接口
Key
public byte[] getEncoded()
getEncoded 接口
Key
public int hashCode()
hashCode 方法重写,继承类
Object
Object.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)
public boolean equals(Object obj)
equals 方法重写,继承类
Object
obj -与此对象相等测试对象。
obj。
Object.hashCode(),
HashMap
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.