Beispiel #1
0
		private void DoInit()
		{
			//Initialize Required Objects
			if (IsMicrosoftCLR())
			{
				fw = new FileWiper();	
				fw.PassInfoEvent += (e) => {};
				fw.SectorInfoEvent += (e) => {};
	            fw.WipeDoneEvent += (e) => {};
	            fw.WipeErrorEvent += (e) => {};
			}
			//Initialize Volume
			string fnwoext = Path.GetFileNameWithoutExtension(RawLocation); //filenamewithout extension
			string volN = RawLocation;
			if (Path.GetExtension(volN)!=".FireCrypt")
				volN = Path.GetDirectoryName(RawLocation)+"\\"+fnwoext+".vault\\"+fnwoext+".FireCrypt";
			VolumeLocation = volN;
			VaultLocation = Path.GetDirectoryName(volN);
			_unlocked = Directory.Exists(OpenVaultLocation);
			_metadata = File.ReadAllText(VaultLocation+"\\vault.metadata");
			var jss = new JavaScriptSerializer();
			MetadataValues = jss.Deserialize<Dictionary<string,string>>(_metadata);
			UID = MetadataValues["UID"];
			Label = MetadataValues["Label"];
			LoadBackwardsCompatiableProperties();
		}
        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;
        }
        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;
        }