Ejemplo n.º 1
0
        public bool ChangePassword(DriveInfo drive, string oldPassword, string newPassword)
        {
            if (ValidPassword(drive))
            {
                string password = GetDrivePassword(drive);

                if (password == oldPassword)
                {
                    XmlDriveSettings dSettings = new XmlDriveSettings(drive.Root);

                    byte[] encPassword = encryptor.EnDecrypt(true, Encoding.Default.GetBytes(newPassword));
                    password = Encoding.Default.GetString(encPassword);
                    dSettings.WritePassword(password);

                    string md5Password = GetMd5Hash(newPassword);
                    dSettings.WriteMd5Password(md5Password);

                    return true;
                }
            }

            return false;
        }
Ejemplo n.º 2
0
        private string GetDrivePassword(DriveInfo drive)
        {
            XmlDriveSettings dSettings = new XmlDriveSettings(drive.Root);
            string password = dSettings.ReadPassword();
            byte[] encPassword = encryptor.EnDecrypt(false, Encoding.Default.GetBytes(password));
            password = Encoding.Default.GetString(encPassword);

            return password;
        }
Ejemplo n.º 3
0
        private bool ValidPassword(DriveInfo drive)
        {
            string password = GetDrivePassword(drive);
            XmlDriveSettings dSettings = new XmlDriveSettings(drive.Root);
            string md5Password = dSettings.ReadMd5Password();

            if (VerifyMd5Hash(password, md5Password))
            {
                return true;
            }

            return false;
        }
Ejemplo n.º 4
0
        private void CreateDriveSettings(DriveInfo drive, string password)
        {
            XmlDriveSettings driveSettings = new XmlDriveSettings(drive.Root);
            driveSettings.WriteMd5Password(GetMd5Hash(password));

            byte[] encPassword = encryptor.EnDecrypt(true, Encoding.Default.GetBytes(password));
            password = Encoding.Default.GetString(encPassword);
            driveSettings.WritePassword(password);
        }