Beispiel #1
0
        public void Loose(string password)
        {
            string hashedPassword = CryptoHelper.GetSHA256HashData(password);

            if (!string.IsNullOrEmpty(this.Password) && this.Password == hashedPassword)
            {
                if (Changed != null)
                {
                    Changed(this, EventArgs.Empty);
                }

                var dbfiles = Directory.GetFiles(Directory.GetParent(this.Path).FullName).Where(s =>
                                                                                                s.EndsWith(".xod") ||
                                                                                                s.EndsWith(".xtab") ||
                                                                                                s.EndsWith(".xpag"));

                foreach (var file in dbfiles)
                {
                    FileCryptoHelper.DecryptFile(file, file + ".lock", hashedPassword);
                    File.Delete(file);
                    File.Move(file + ".lock", file);
                }
                this.Password = null;
            }
            else
            {
                throw new SecurityException("Input password doesn't match current database password.");
            }
        }