Bonjour,

En fouillant un peu sur internet je suis tombé sur ce code, qui est d'après ce que j'ai compris est une base de cryptage Xor:

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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace XOREncryption
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private string XorEncrypt(string text, int key)
        {
            string newText = "";
 
            for (int i = 0; i < text.Length; i++)
            {
                int charValue = Convert.ToInt32(text[i]); //get the ASCII value of the character
                charValue ^= key; //xor the value
 
                newText += char.ConvertFromUtf32(charValue); //convert back to string
            }
 
            return newText;
        }
 
 
    }
}
Je le comprend dans son ensemble mais est-ce que quelqu'un pourrais m'expliquer un peu plus en détail ce code et si on peut l'optimiser.

Merci d'avance