Code example for DESKeySpec

0
            } 
        } 
 
        // Convert the raw bytes to a secret key like this 
        // DESedeKeySpec keyspec = new DESedeKeySpec(rawkey); 
        DESKeySpec keyspec = new DESKeySpec(rawkey);
        // SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("DESede"); 
 
        SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("DES");
        // /ECB/PKCS5Padding 
 
        SecretKey key = keyfactory.generateSecret(keyspec);
 
        return key;
    } 
 
    public void generateNewKey() throws NoSuchAlgorithmException, 
            InvalidKeySpecException, IOException { 
 
        if (writeEncrypt) {
            // Get a key generator for Triple DES (a.k.a DESede)