• XSS.stack #1 – первый литературный журнал от юзеров форума

[C#] Basic .exe and .bat AES crypter

Xzedin

RAID-массив
Пользователь
Регистрация
16.04.2023
Сообщения
65
Реакции
7
As said in the title:

using System.IO;
using System.Security.Cryptography;

class Program
{
static void Main()
{
string inputFile = "your_file.exe"; // replace with your file name/path
string outputFile = "encrypted_file.exe"; // set the encrypted file name

// create random AES key (for symmetric encryption)
byte[] key = new byte[32];
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
{
rng.GetBytes(key);
}

// read in the input file
byte[] bytesToEncrypt = File.ReadAllBytes(inputFile);

// encrypt the input file bytes with AES
byte[] encryptedBytes = null;
using (Aes aesAlg = Aes.Create())
{
aesAlg.Key = key;
aesAlg.GenerateIV();
ICryptoTransform encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
using (MemoryStream msEncrypt = new MemoryStream())
{
using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
{
csEncrypt.Write(bytesToEncrypt, 0, bytesToEncrypt.Length);
csEncrypt.FlushFinalBlock();
encryptedBytes = msEncrypt.ToArray();
}
}
}

// write out the encrypted bytes to a file
File.WriteAllBytes(outputFile, encryptedBytes);
}
}
 
Последнее редактирование:
Пожалуйста, обратите внимание, что пользователь заблокирован
As said in the title:

Скрытое содержимое
What about decryption of encrypted file?
/ write out the encrypted bytes to a
file - but decryption process is missing :)
 
Последнее редактирование:


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх