Salut à tous

je suis face à un problème de perf pour l'encryption de gros fichiers XML avec un algo AES_128

en effet la transformation prend près de 10 minutes pour un fichier de 3 Mo environ (25 000 noeuds)

voici le code utilisé :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
        Document document = null;
        try {
            document = readDocument(file.getFileName());
        } catch (Exception e) {
            //gestion de l'exception
            return;
        }
 
        /*
         * Get a key to be used for encrypting the element. Here we are generating an AES key.
         */
        Key symmetricKey = null;
        try {
            symmetricKey = GenerateDataEncryptionKey();
        } catch (Exception e) {
            //gestion de l'exception
            return;
        }
        try {
 
            String algorithmURI = XMLCipher.RSA_v1dot5;
 
            XMLCipher keyCipher = XMLCipher.getInstance(algorithmURI);
            keyCipher.init(XMLCipher.WRAP_MODE, publicKey);
            EncryptedKey encryptedKey = keyCipher.encryptKey(document, symmetricKey);
 
            /*
             * Let us encrypt the contents of the document element.
             */
            Element rootElement = document.getDocumentElement();
 
            algorithmURI = XMLCipher.AES_128;
 
            XMLCipher xmlCipher = XMLCipher.getInstance(algorithmURI);
            xmlCipher.init(XMLCipher.ENCRYPT_MODE, symmetricKey);
 
            /*
             * Setting keyinfo inside the encrypted data being prepared.
             */
            EncryptedData encryptedData = xmlCipher.getEncryptedData();
            KeyInfo keyInfo = new KeyInfo(document);
            keyInfo.add(encryptedKey);
            encryptedData.setKeyInfo(keyInfo);
 
 
            xmlCipher.doFinal(document, rootElement, true);
        } catch (Exception e) {
            //gestion de l'excption
            return;
        }
vous avez une idée du pourquoi de la lenteur ?
(c'est pas la machine, y'a 3Go de RAM dessus et que çà qui tourne (ou presque)
je n'y connais pas grand chose en cryptage/decryptage en java, mais si vous avez des conseils/autres apis etc. à donner pour effectuer un cryptage/decryptage rapide de gros fichiers en java çà m'intéresse

(ps: je sais que java c'est pas ce qu'il y a de plus rapide pour le parsing et lecture de fichier ... mais bon)