using System.Security.Cryptography;
const string idylis_IV = "i8yg0p5i";
const string idylis_Key = "le mont blanc est le top";
Main2("CodeAbonne¤CodeUser");
static void Main2(string text)
TripleDESCryptoServiceProvider TDES = new TripleDESCryptoServiceProvider();
byte[] iv = Encoding.ASCII.GetBytes(idylis_IV);
byte[] key = Encoding.ASCII.GetBytes(idylis_Key);
Console.WriteLine("Mon texte en clair : {0}", text);
byte[] cryptedTextAsByte = Crypt(text, key, iv);
Console.WriteLine("Mon texte chiffré : {0}", Convert.ToBase64String(cryptedTextAsByte));
String decryptedText = Decryp(cryptedTextAsByte, key, iv);
Console.WriteLine("Mon texte déchiffré : {0}", decryptedText);
static byte[] Crypt(string text, byte[] key, byte[] iv)
byte[] textAsByte = Encoding.Default.GetBytes(text);
TripleDESCryptoServiceProvider TDES = new TripleDESCryptoServiceProvider();
var encryptor = TDES.CreateEncryptor(key, iv);
byte[] cryptedTextAsByte = encryptor.TransformFinalBlock(textAsByte, 0, textAsByte.Length);
return cryptedTextAsByte;
static string Decryp(byte[] cryptedTextAsByte, byte[] key, byte[] iv)
TripleDESCryptoServiceProvider TDES = new TripleDESCryptoServiceProvider();
var decryptor = TDES.CreateDecryptor(key, iv);
byte[] decryptedTextAsByte = decryptor.TransformFinalBlock(cryptedTextAsByte, 0, cryptedTextAsByte.Length);
return Encoding.Default.GetString(decryptedTextAsByte);