當前位置: 首頁>>代碼示例>>Java>>正文


Java DESedeKeySpec.getKey方法代碼示例

本文整理匯總了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());
    }
}
 
開發者ID:google,項目名稱:conscrypt,代碼行數:25,代碼來源:DESEDESecretKeyFactory.java

示例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;
}
 
開發者ID:openjdk,項目名稱:jdk7-jdk,代碼行數:29,代碼來源:DESedeKeyFactory.java

示例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);
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:13,代碼來源:DESede.java

示例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);
    }
}
 
開發者ID:freeVM,項目名稱:freeVM,代碼行數:14,代碼來源:TestDESedeKeySpec.java


注:本文中的javax.crypto.spec.DESedeKeySpec.getKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。