Search in sources :

Example 11 with DESedeKeySpec

use of javax.crypto.spec.DESedeKeySpec in project smartmodule by carozhu.

the class ThreeDESUtil method keyGenerator.

/**
     *
     * 生成密钥key对象
     * @param keyStr 密钥字符串
     * @return 密钥对象
     * @throws InvalidKeyException
     * @throws NoSuchAlgorithmException
     * @throws InvalidKeySpecException
     * @throws Exception
     */
private static Key keyGenerator(String keyStr) throws Exception {
    byte[] input = HexString2Bytes(keyStr);
    DESedeKeySpec KeySpec = new DESedeKeySpec(input);
    SecretKeyFactory KeyFactory = SecretKeyFactory.getInstance(KEY_ALGORITHM);
    return ((Key) (KeyFactory.generateSecret(((java.security.spec.KeySpec) (KeySpec)))));
}
Also used : DESedeKeySpec(javax.crypto.spec.DESedeKeySpec) SecretKeyFactory(javax.crypto.SecretKeyFactory)

Aggregations

DESedeKeySpec (javax.crypto.spec.DESedeKeySpec)11 SecretKeyFactory (javax.crypto.SecretKeyFactory)8 KeySpec (java.security.spec.KeySpec)6 DESKeySpec (javax.crypto.spec.DESKeySpec)6 InvalidKeyException (java.security.InvalidKeyException)4 SecretKeySpec (javax.crypto.spec.SecretKeySpec)4 Key (java.security.Key)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 Cipher (javax.crypto.Cipher)3 IvParameterSpec (javax.crypto.spec.IvParameterSpec)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2 InputStream (java.io.InputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)2 NoSuchPaddingException (javax.crypto.NoSuchPaddingException)2 SecretKey (javax.crypto.SecretKey)2 MyCipher (org.apache.harmony.crypto.tests.support.MyCipher)2 PrivateKey (java.security.PrivateKey)1 PublicKey (java.security.PublicKey)1