private int DecideTemplateOperations(string fileName) { var type = NLockTemplateOperations.IsNLock(fileName); Logger.Debug("DecideTemplateOperations Type : " + type); switch (type) { case 1: TemplateOperations = new NLockTemplateOperationsAes(); break; case 2: TemplateOperations = new NLockTemplateOperationsCommon(); break; default: Logger.Error("Invalid NLock file type"); break; } return(type); }
private void VerifyWithPassword() { lblInfo.Text = Resources.Verifying_using_password____; Verified = false; if (tbPw.Text != null && PwHash != null) { if (NLockTemplateOperationsCommon.ValidatePassword(NLockTemplateOperations.GetBytes(tbPw.Text), PwHash)) { Verified = true; DialogResult = DialogResult.OK; } else { lblInfo.Text = Resources.Invalid_password___; _currentop = Ops.Verificationfailedretry; EnableRetryCounter(); } } else if (PwHash == null) { lblHelpText.Text = Resources.Password_not_supported; lblInfo.Text = Resources.Failed___; llblRetryWithPW.Enabled = false; llblRetryWithPW.Visible = false; tbPw.Enabled = false; tbPw.Visible = false; _retryWithPw = false; _currentop = Ops.Passwordnotsupported; } else { lblInfo.Text = Resources.Invalid_password___; _currentop = Ops.Verificationfailedretry; } }
private void ToolstripButtonOpenClick(object sender, EventArgs e) { tssStatus.ForeColor = Color.Blue; tssStatus.Text = Resources.Opening___; try { if (openFileDialog.ShowDialog() == DialogResult.OK) { FilelistView.Items.Clear(); Text = Resources.NLock; toolStripFileCountLabel.Text = string.Empty; tssStatus.ForeColor = Color.Blue; tssStatus.Text = Resources.Unlocking___; if (NLockTemplateOperations.IsNLock(openFileDialog.FileName) > 0) { if (_nlockContainer != null) { _nlockContainer.Dispose(); } _nlockContainer = new NLockContainerCommons(); _isDirty = false; _fileName = openFileDialog.FileName; _nlockContainer.LoadFromFile(_fileName); if (!_nlockContainer.IsLocked) { Text = Resources.NLock + _fileName; UpdateListView(_nlockContainer.GetFileList()); tsbExtract.Enabled = true; tssStatus.ForeColor = Color.Green; tssStatus.Text = Resources.UnlockedUserIdentified; } else { _fileName = null; } } else { MessageBox.Show( Resources.FileCorrupted + Path.GetFileName(openFileDialog.FileName), Resources.FileOpeningFailed, MessageBoxButtons.OK, MessageBoxIcon.Error); tssStatus.ForeColor = Color.Red; tssStatus.Text = Resources.Unlocking___ + Resources.Failed; } } else { tssStatus.ForeColor = Color.Blue; tssStatus.Text = Resources.Canceled___; } } catch (Exception) { _fileName = null; tssStatus.ForeColor = Color.Red; tssStatus.Text = Resources.UnlockingFailed; Logger.Info("Unlocking... Failed"); } }