Criptografia

alguem poderia me passar alguma dicas sobre algoritmo DES ou AES precisa implementar.
Sites ou livros ate um tutorial seria bem vindo.
rafa.

Olá Rafael, no livro Criptografia e Segurança – O Guia Oficial RSA
vc poderá obter boas dicas sobre como usar estes algoritmos. Aqui no portal tem uma resenha sobre o livro. No site http://www.javaworld.com/javaworld/jw-10-2000/jw-1027-aes_p.html vc também pode encontrar alguma informação que possa lhe interessar.

Vê se te ajuda:


/** It indicates what kind of Cipher instance will be created. */
transient private static final String CIPHER_TYPE = "DES/ECB/PKCS5Padding";

/** It indicates the key type to be generated. */
transient private static final String KEY_TYPE = "DES";

/** Cipher object used to encode/decode data. */
transient private final Cipher cipher;

public final String encode(final String keyPath, final byte[] data)
            throws InvalidKeyException, IllegalBlockSizeException,
            BadPaddingException, NoSuchAlgorithmException, IOException,
            ClassNotFoundException {

        initKey(keyPath);
        cipher.init(Cipher.ENCRYPT_MODE, key);
        final byte[] raw = cipher.doFinal(data);
        final BASE64Encoder encoder = new BASE64Encoder();
        return encoder.encode(raw);
}

public final byte[] decode(final String keyPath, final byte[] data)
            throws InvalidKeyException, IllegalBlockSizeException,
            BadPaddingException, IOException, NoSuchAlgorithmException,
            ClassNotFoundException {

        initKey(keyPath);
        cipher.init(Cipher.DECRYPT_MODE, key);
        final BASE64Decoder decoder = new BASE64Decoder();
        final ByteArrayInputStream bais = new ByteArrayInputStream(data);
        final byte[] raw = decoder.decodeBuffer(bais);
        return cipher.doFinal(raw);
 }

private void initKey(final String keyPath) throws IOException,
            ClassNotFoundException, NoSuchAlgorithmException {

        final File keyFile = new File(keyPath);
        try {

            final ObjectInputStream objectIStream = new ObjectInputStream(
                    new FileInputStream(keyFile));

            key = (Key) objectIStream.readObject();
            objectIStream.close();

            LOG.debug("DataObfuscartor key loaded.");
        } catch (FileNotFoundException fnfe) {

            final KeyGenerator generator = KeyGenerator.getInstance(KEY_TYPE);
            generator.init(new SecureRandom());
            key = generator.generateKey();
            final ObjectOutputStream objectOStream = new     ObjectOutputStream(new FileOutputStream(keyFile));

            objectOStream.writeObject(key);
            objectOStream.close();
        }
}

Acho que já deve te dar uma boa noção, T+