本文整理匯總了Java中javax.crypto.spec.DESedeKeySpec.getKey方法的典型用法代碼示例。如果您正苦於以下問題:Java DESedeKeySpec.getKey方法的具體用法?Java DESedeKeySpec.getKey怎麽用?Java DESedeKeySpec.getKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.crypto.spec.DESedeKeySpec
的用法示例。
在下文中一共展示了DESedeKeySpec.getKey方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: engineGenerateSecret
import javax.crypto.spec.DESedeKeySpec; //導入方法依賴的package包/類
@Override
protected SecretKey engineGenerateSecret(KeySpec keySpec) throws InvalidKeySpecException {
if (keySpec == null) {
throw new InvalidKeySpecException("Null KeySpec");
}
if (keySpec instanceof SecretKeySpec) {
SecretKeySpec key = (SecretKeySpec) keySpec;
try {
if (!DESedeKeySpec.isParityAdjusted(key.getEncoded(), 0)) {
throw new InvalidKeySpecException(
"SecretKeySpec is not a parity-adjusted DESEDE key");
}
} catch (InvalidKeyException e) {
throw new InvalidKeySpecException(e);
}
return key;
} else if (keySpec instanceof DESedeKeySpec) {
DESedeKeySpec desKeySpec = (DESedeKeySpec) keySpec;
return new SecretKeySpec(desKeySpec.getKey(), "DESEDE");
} else {
throw new InvalidKeySpecException(
"Unsupported KeySpec class: " + keySpec.getClass().getName());
}
}
示例2: engineGenerateSecret
import javax.crypto.spec.DESedeKeySpec; //導入方法依賴的package包/類
/**
* Generates a <code>SecretKey</code> object from the provided key
* specification (key material).
*
* @param keySpec the specification (key material) of the secret key
*
* @return the secret key
*
* @exception InvalidKeySpecException if the given key specification
* is inappropriate for this key factory to produce a public key.
*/
protected SecretKey engineGenerateSecret(KeySpec keySpec)
throws InvalidKeySpecException {
DESedeKey desEdeKey = null;
try {
if (keySpec instanceof DESedeKeySpec) {
DESedeKeySpec desEdeKeySpec = (DESedeKeySpec)keySpec;
desEdeKey = new DESedeKey(desEdeKeySpec.getKey());
} else {
throw new InvalidKeySpecException
("Inappropriate key specification");
}
} catch (InvalidKeyException e) {
}
return desEdeKey;
}
示例3: engineGenerateSecret
import javax.crypto.spec.DESedeKeySpec; //導入方法依賴的package包/類
protected SecretKey engineGenerateSecret(
KeySpec keySpec)
throws InvalidKeySpecException
{
if (keySpec instanceof DESedeKeySpec)
{
DESedeKeySpec desKeySpec = (DESedeKeySpec)keySpec;
return new SecretKeySpec(desKeySpec.getKey(), "DESede");
}
return super.engineGenerateSecret(keySpec);
}
示例4: testGetKey001
import javax.crypto.spec.DESedeKeySpec; //導入方法依賴的package包/類
public final void testGetKey001() {
offset = 2;
try {
deks = new DESedeKeySpec(Hex.decode(NONPARITY_ADJUSTED_KEYS), offset);
for (int i = 0; i < deks.getKey().length; i++) {
assertEquals("Not the same array element", Hex
.decode(NONPARITY_ADJUSTED_KEYS)[i + offset], deks
.getKey()[i]);
}
} catch (Throwable e) {
fail(msgNoException);
}
}