Today i have to use c# to crypt some data using 3des, so here is a pretty basic example to do it, i test it using mono.
-
-
using System;
-
using System.Security.Cryptography; // used for TripleDESCryptoServiceProvider
-
using System.Text; // used for Encoding.ASCII.GetBytes
-
// i create the 3des object
-
byte[] key = Encoding.ASCII.GetBytes("123456781234567812345678"); // the key should be 24 chars long
-
"Here goes the data to encrypt";
-
des.Mode = CipherMode.CBC; // We’ll use CBC
-
des.Key = key; // I set the key
-
byte[] iv = des.IV; // I store the randomly generated IV since i will need for decrypt
-
// i will print as readble data
Great . Simple and to the point .