示例#1
0
        public void UnlockVolume(string key)
        {
            string eVolume           = File.ReadAllBytes(VolumeLocation).GetString();
            string unlockName        = UnlockLocation + UID;
            string DecVolumeLocation = unlockName + ".dec";

            if (!Directory.Exists(UnlockLocation))
            {
                Directory.CreateDirectory(UnlockLocation);
            }
            if (Directory.Exists(unlockName))
            {
                Directory.Delete(unlockName, true);
            }
            File.WriteAllBytes(DecVolumeLocation, PowerAES.Decrypt(eVolume, key).GetBytes());
            ZipFile.ExtractToDirectory(DecVolumeLocation, unlockName);
            FileWiper fw = new FileWiper();

            fw.PassInfoEvent   += (e) => {};
            fw.SectorInfoEvent += (e) => {};
            fw.WipeDoneEvent   += (e) => {};
            fw.WipeErrorEvent  += (e) => {};
            fw.WipeFile(DecVolumeLocation, 1);
            _unlocked   = true;
            _unlockPath = unlockName;
        }
示例#2
0
 public void Unlock_2_0(string key)
 {
     string unlockName = UnlockLocation + UID;
     string DecVolumeLocation = unlockName + ".dec";
     if (!Directory.Exists(UnlockLocation))
     {
         Directory.CreateDirectory(UnlockLocation);
     }
     if (Directory.Exists(unlockName))
     {
         fw.RecursivelyWipeDirectory(unlockName);
         Directory.Delete(unlockName, true);
     }
     int bufSize = SelectBufferSize();
     byte[] encryptedFileBuffer = new byte[bufSize]; //128 Mebibytes, 134.2 Megabytes
     byte[] decryptionBuffer1; //128 Mebibytes, 134.2 Megabytes
     //Buffered-read and decrypt and write to the output file
     using (var encryptedFileStream = File.Open(VolumeLocation, FileMode.Open, FileAccess.ReadWrite))
     {
         using (var rawFileStream = File.Open(DecVolumeLocation, FileMode.Create, FileAccess.ReadWrite))
         {
             using (var encryptedFileReader = new BinaryReader(encryptedFileStream))
             {
                 using (var rawFileWriter = new BinaryWriter(rawFileStream))
                 {
                     int bytesRead;
                     while ((bytesRead = encryptedFileReader.Read(encryptedFileBuffer, 0, bufSize)) > 0)
                     {
                         //Slice buffer
                         decryptionBuffer1 = PowerAES.Decrypt(encryptedFileBuffer.Take(bytesRead).ToArray().GetString(), key).GetBytes();
                         rawFileWriter.Write(decryptionBuffer1, 0, decryptionBuffer1.Length);
                     }
                 }
             }
         }
     }
     ZipFile.ExtractToDirectory(DecVolumeLocation, unlockName);
     fw.WipeFile(DecVolumeLocation, 1);
     _unlocked = true;
     _unlockPath = unlockName;
 }
        public void Unlock_1_0(string key)
        {
            string eVolume           = File.ReadAllBytes(VolumeLocation).GetString();
            string unlockName        = UnlockLocation + UID;
            string DecVolumeLocation = unlockName + ".dec";

            if (!Directory.Exists(UnlockLocation))
            {
                Directory.CreateDirectory(UnlockLocation);
            }
            if (Directory.Exists(unlockName))
            {
                fw.RecursivelyWipeDirectory(unlockName);
                Directory.Delete(unlockName, true);
            }
            File.WriteAllBytes(DecVolumeLocation, PowerAES.Decrypt(eVolume, key).GetBytes());
            ZipFile.ExtractToDirectory(DecVolumeLocation, unlockName);
            fw.WipeFile(DecVolumeLocation, 1);
            _unlocked   = true;
            _unlockPath = unlockName;
        }
示例#4
0
        public void LockVolume(string key)
        {
            string unlockName        = UnlockLocation + UID;
            string DecVolumeLocation = unlockName + ".dec";

            if (File.Exists(DecVolumeLocation))
            {
                File.Delete(DecVolumeLocation);
            }
            ZipFile.CreateFromDirectory(unlockName, DecVolumeLocation);
            Directory.Delete(unlockName, true);
            string    dVolume = File.ReadAllBytes(DecVolumeLocation).GetString();
            FileWiper fw      = new FileWiper();

            fw.PassInfoEvent   += (e) => {};
            fw.SectorInfoEvent += (e) => {};
            fw.WipeDoneEvent   += (e) => {};
            fw.WipeErrorEvent  += (e) => {};
            fw.WipeFile(DecVolumeLocation, 1);
            File.WriteAllBytes(VolumeLocation, PowerAES.Encrypt(dVolume, key).GetBytes());
            _unlocked   = false;
            _unlockPath = null;
        }