public static byte[] desDecrypt(byte rawKeyData[], byte[] encryptedData)
            throws IllegalBlockSizeException, BadPaddingException,
            InvalidKeyException, NoSuchAlgorithmException,
            NoSuchPaddingException, InvalidKeySpecException {
        // DES算法要求有一个可信任的随机数源
        SecureRandom sr = new SecureRandom();
        // 从原始密匙数据创建一个DESKeySpec对象
        DESKeySpec dks = new DESKeySpec(rawKeyData);
        // 创建一个密匙工厂，然后用它把DESKeySpec对象转换成一个SecretKey对象
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
        SecretKey key = keyFactory.generateSecret(dks);
        // Cipher对象实际完成解密操作
        Cipher cipher = Cipher.getInstance("DES");
        // 用密匙初始化Cipher对象
        cipher.init(Cipher.DECRYPT_MODE, key, sr);
        // 正式执行解密操作
        byte decryptedData[] = cipher.doFinal(encryptedData);
//        System.out.println("解密后===>" + new String(decryptedData));
        return decryptedData;
    }
public static byte[] desDecrypt(byte rawKeyData[], byte[] encryptedData)
            throws IllegalBlockSizeException, BadPaddingException,
            InvalidKeyException, NoSuchAlgorithmException,
            NoSuchPaddingException, InvalidKeySpecException {
        
        SecureRandom sr = new SecureRandom();
        
        DESKeySpec dks = new DESKeySpec(rawKeyData);
        
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
        SecretKey key = keyFactory.generateSecret(dks);
        
        Cipher cipher = Cipher.getInstance("DES");
        
        cipher.init(Cipher.DECRYPT_MODE, key, sr);
        
        byte decryptedData[] = cipher.doFinal(encryptedData);

        return decryptedData;
    }
public static byte [ ] desDecrypt ( byte rawKeyData [ ] , byte [ ] encryptedData ) throws IllegalBlockSizeException , BadPaddingException , InvalidKeyException , NoSuchAlgorithmException , NoSuchPaddingException , InvalidKeySpecException { // DES算法要求有一个可信任的随机数源 SecureRandom sr = new SecureRandom ( ) ; // 从原始密匙数据创建一个DESKeySpec对象 DESKeySpec dks = new DESKeySpec ( rawKeyData ) ; // 创建一个密匙工厂，然后用它把DESKeySpec对象转换成一个SecretKey对象 SecretKeyFactory keyFactory = SecretKeyFactory . getInstance ( "DES" ) ; SecretKey key = keyFactory . generateSecret ( dks ) ; // Cipher对象实际完成解密操作 Cipher cipher = Cipher . getInstance ( "DES" ) ; // 用密匙初始化Cipher对象 cipher . init ( Cipher . DECRYPT_MODE , key , sr ) ; // 正式执行解密操作 byte decryptedData [ ] = cipher . doFinal ( encryptedData ) ; //        System.out.println("解密后===>" + new String(decryptedData)); return decryptedData ; }
解密方法

@param rawKeyData
@param encryptedData
@return byte[]
@throws IllegalBlockSizeException
@throws BadPaddingException
@throws InvalidKeyException
@throws NoSuchAlgorithmException
@throws NoSuchPaddingException
@throws InvalidKeySpecException
解密方法