import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.*;

// --------------------------------------------------
// Exemple d'utilisation du JCE
// Generation d'une paire de cles publique/privee
// --------------------------------------------------

class TestJCE01 {
    private static void genererCles() {
	// Indications:
	//    - utiliser l'algo "SHA1PRNG" pour generer le nombre aleatoire
	//    - utiliser l'algo "RSA" pour generer la paire de cles
    }
	
    private static byte[] crypter(String msg) {
	// Indications:
	//    - utiliser la combinaison "RSA/ECB/PKCS1Padding" pour creer le Cipher
	//    - penser a convertir la String en byte[] via la methode getBytes() avant de chiffrer
    }
	
    private static String decrypter(byte[] buffer) {
	// Idem ci-dessus...
    }
	
    public static void main(String[] args) {
	if (args.length<1)
	    {
		System.out.println("Usage: java TestJCE01 <message>");
		System.exit(0);
	    }
	
	String theMessage = args[0];
	genererCles();
	
	System.out.println("message initial = \""+theMessage+"\"");
	byte[] buf = crypter(theMessage);
	System.out.println("message crypte  = \""+(new String(buf))+"\"");
	String msg = decrypter(buf);
	System.out.println("message final   = \""+msg+"\"");
    }
}
