private void Decrypt(string fileName) { if (File.Exists(fileName)) { try { BasylPseudoAdaptator adaptor = null; if (advancedSettingsForm.GetGenerationMode()) { adaptor = new StrongerBasylPseudoAdaptor(advancedSettingsForm.GetSeedFunction()); } else { adaptor = new SeedFunctionStringAdaptor(advancedSettingsForm.GetSeedFunction()); } if (Path.GetExtension(fileName).Equals(".bcs") || Path.GetExtension(fileName).Equals("bcs")) { string name = fileName.Substring(0, fileName.LastIndexOf(Path.GetExtension(fileName))); BasylCipherFileEncryption.Decrypt(fileName, name, passwordTextbox.Text, advancedSettingsForm.GetInitial(), advancedSettingsForm.GetRounds(), advancedSettingsForm.GetLeftoff(), advancedSettingsForm.GetExpand(), advancedSettingsForm.GetKey(), UpdateProgress, adaptor); } else if (Path.GetExtension(fileName).Equals(".bes") || Path.GetExtension(fileName).Equals("bes")) { string name = fileName.Substring(0, fileName.LastIndexOf(Path.GetExtension(fileName))); BasylFileEncryption.Decrypt(fileName, name, passwordTextbox.Text, advancedSettingsForm.GetInitial(), advancedSettingsForm.GetRounds(), advancedSettingsForm.GetLeftoff(), advancedSettingsForm.GetExpand(), advancedSettingsForm.GetKey(), UpdateProgress, adaptor); } else { //not a valid file extension. } } catch (Exception ex) { MessageBox.Show("There must be an error. Do you have permissions?"); } } }
private void Encrypt(string fileName) { if (File.Exists(fileName)) { try { BasylPseudoAdaptator adaptor = null; if (advancedSettingsForm.GetGenerationMode()) { adaptor = new StrongerBasylPseudoAdaptor(advancedSettingsForm.GetSeedFunction()); } else { adaptor = new SeedFunctionStringAdaptor(advancedSettingsForm.GetSeedFunction()); } if (advancedSettingsForm.GetCipherMode()) { string name = fileName + ".bcs"; BasylCipherFileEncryption.Encrypt(fileName, name, passwordTextbox.Text, advancedSettingsForm.GetInitial(), advancedSettingsForm.GetRounds(), advancedSettingsForm.GetLeftoff(), advancedSettingsForm.GetExpand(), advancedSettingsForm.GetKey(), UpdateProgress, adaptor); } else { string name = fileName + ".bes"; BasylFileEncryption.Encrypt(fileName, name, passwordTextbox.Text, advancedSettingsForm.GetInitial(), advancedSettingsForm.GetRounds(), advancedSettingsForm.GetLeftoff(), advancedSettingsForm.GetExpand(), advancedSettingsForm.GetKey(), UpdateProgress, adaptor); } } catch (Exception ex) { MessageBox.Show("There must be an error. Do you have permissions?"); } } }
private BasylPseudoAdaptator GetAdaptor() { BasylPseudoAdaptator adaptor = null; if (advForm.GetGenerationMode()) { adaptor = new StrongerBasylPseudoAdaptor(advForm.GetSeedFunction()); } else { adaptor = new SeedFunctionStringAdaptor(advForm.GetSeedFunction()); } return adaptor; }