using System.Security.Cryptography;
var tdese = TripleDES.Create();tdese.Mode = CipherMode.ECB;tdese.Padding = PaddingMode.PKCS7;tdese.Key = ConvertHexStringToByteArray("AABBCCDDEE11223344556677889900FF");var encryptor = tdese.CreateEncryptor();
public static byte[] ConvertHexStringToByteArray(string hexString)
{
if (hexString.Length % 2 != 0)
{
throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "The binary key cannot have an odd number of digits: {0}", hexString));
}

byte[] HexAsBytes = new byte[hexString.Length / 2];
for (int index = 0; index < HexAsBytes.Length; index++)
{
string byteValue = hexString.Substring(index * 2, 2);

if (byteValue == " ")
{
HexAsBytes[index] = Convert.ToByte("32");
}
else
{
HexAsBytes[index] = byte.Parse(byteValue, NumberStyles.HexNumber, CultureInfo.InvariantCulture);
}
}

return HexAsBytes;
}
byte[] result = null;byte[] data = File.ReadAllBytes("FileToEncrypt.txt");using (var mse = new MemoryStream()){using (var cs = new CryptoStream(mse, encryptor, CryptoStreamMode.Write))cs.Write(data, 0, data.Length);result = mse.ToArray();}if (result != null){string encrypteddata = UTF8Encoding.Default.GetString(result);File.AppendAllText("OutputFileName" + ".enc", encrypteddata, UTF8Encoding.Default);}

--

--

--

www.vengito.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

First they got into emails, then onto WhatsApp, and now Telegram is the latest playing field for…

How I exposed the teacher’s Aadhaar card, bank details on the college website.

How to open a Royal-Q account and Bind with Binance

Threat Intelligence Alerts — Daily (April 01 2021)

Cloud Security Posture Management (CSPM)

{UPDATE} MineBlock - Craft and Build Hack Free Resources Generator

What is encryption and why do I need it?

BitMax.io Weekly Roundup | Jan 8 — Jan 15, 2021

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vengito

Vengito

www.vengito.com

More from Medium

Supervisor periodic restart

How to insert array values to a file using the sed command?

Solving Jenkins “stderr=Host key verification failed” problem when all else fails

Deployment flow (Github -> Jenkins -> Remote -> AWS ECR)

GitLab commands for beginners and everyday users