Bug 228046. Prompt user for MasterPassword prior to

displaying the Find and Replace dialog.
This commit is contained in:
Jim Norman 2007-01-09 08:41:54 +00:00
parent 434bc49a50
commit bdc46f5639
2 changed files with 292 additions and 282 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Tue Jan 9 13:25:55 MST 2007 - jnorman@novell.com
- Bug 228046. Prompt user for MasterPassword prior to displaying
the Find and Replace dialog.
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Jan 9 12:27:57 MST 2007 - jnorman@novell.com Tue Jan 9 12:27:57 MST 2007 - jnorman@novell.com

View File

@ -25,7 +25,7 @@ namespace Novell.CASA.GUI {
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Threading; using System.Threading;
using Gtk; using Gtk;
@ -47,11 +47,11 @@ public class MiCasa : Store
ArrayList arrDeletedKeys = null; ArrayList arrDeletedKeys = null;
private SecretStore m_store = null; private SecretStore m_store = null;
private int m_iRememberSeconds = 5; private int m_iRememberSeconds = 5;
private String m_sRememberFor = "5"; private String m_sRememberFor = "5";
private Config m_config = null; private Config m_config = null;
#region Glade Widgets #region Glade Widgets
@ -79,7 +79,7 @@ public class MiCasa : Store
dialogDecode; dialogDecode;
[Glade.Widget] [Glade.Widget]
Gtk.Menu menuRightClick, Gtk.Menu menuRightClick,
menuRightClickKeyValue; menuRightClickKeyValue;
[Glade.Widget] [Glade.Widget]
@ -93,15 +93,15 @@ public class MiCasa : Store
[Glade.Widget] [Glade.Widget]
Gtk.CheckButton cbuttonShowPassword, Gtk.CheckButton cbuttonShowPassword,
checkbuttonShowDeleteDialog; checkbuttonShowDeleteDialog;
[Glade.Widget] [Glade.Widget]
Gtk.MenuItem cmiNewKey, Gtk.MenuItem cmiNewKey,
cmiDelete, cmiDelete,
cmiView, cmiView,
cmiLink, cmiLink,
cmiCopy, cmiCopy,
menuItemLinkKey, menuItemLinkKey,
menuItemDecodeValue; menuItemDecodeValue;
@ -112,24 +112,24 @@ public class MiCasa : Store
Gtk.Label labelLinkSecretID, Gtk.Label labelLinkSecretID,
labelLinkKeyID, labelLinkKeyID,
label86, label86,
label88, label88,
labelRememberFor, labelRememberFor,
labelSeconds; labelSeconds;
[Glade.Widget] [Glade.Widget]
Gtk.SpinButton spinbuttonRememberFor; Gtk.SpinButton spinbuttonRememberFor;
[Glade.Widget] [Glade.Widget]
Gtk.TextView textviewEncoded, Gtk.TextView textviewEncoded,
textviewClear; textviewClear;
[Glade.Widget] [Glade.Widget]
Gtk.Button bttnDecode, Gtk.Button bttnDecode,
bttnEncode, bttnEncode,
bttnExpand, bttnExpand,
bttnCloseDecode; bttnCloseDecode;
[Glade.Widget] [Glade.Widget]
Gtk.ScrolledWindow scrolledwindowEncoded; Gtk.ScrolledWindow scrolledwindowEncoded;
#endregion #endregion
@ -148,9 +148,9 @@ public class MiCasa : Store
m_config = config; m_config = config;
/// SecretID TreeStore /// SecretID TreeStore
tvSecretIDMiCasa = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvSecretIDMiCasa"); tvSecretIDMiCasa = (Gtk.TreeView)CasaMain.gxmlMain.GetWidget("tvSecretIDMiCasa");
tsSecretIDMiCasa = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[])); tsSecretIDMiCasa = new TreeStore(typeof(string), typeof(string[]), typeof(string[]), typeof(string), typeof(string[]), typeof(string[]));
tvSecretIDMiCasa.AppendColumn("Secret ID",new CellRendererText(),"text",0); tvSecretIDMiCasa.AppendColumn("Secret ID",new CellRendererText(),"text",0);
tvSecretIDMiCasa.Model = tsSecretIDMiCasa; tvSecretIDMiCasa.Model = tsSecretIDMiCasa;
tsSecretIDMiCasa.SetSortColumnId(0, Gtk.SortType.Ascending); tsSecretIDMiCasa.SetSortColumnId(0, Gtk.SortType.Ascending);
tvSecretIDMiCasa.RowActivated += new RowActivatedHandler(OntvSecretIDMiCasaRowActivated); tvSecretIDMiCasa.RowActivated += new RowActivatedHandler(OntvSecretIDMiCasaRowActivated);
@ -311,17 +311,17 @@ public class MiCasa : Store
cellEditable = new CellRendererText(); cellEditable = new CellRendererText();
cellEditable.Editable = true; cellEditable.Editable = true;
cellEditable.Edited += new EditedHandler(OnKeyValueEdited); cellEditable.Edited += new EditedHandler(OnKeyValueEdited);
/// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4 /// KEY:0 VALUE:1 VALUE-DUP:2 DIRTY-BIT:3 LINK:4
tsKeyValue = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(string)); tsKeyValue = new TreeStore(typeof(string), typeof(string), typeof(string), typeof(bool), typeof(string), typeof(string), typeof(string));
tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0); tvKeyValue.AppendColumn("Key",new CellRendererText(),"text",0);
tvKeyValue.AppendColumn("Value",cellEditable,"text",2); tvKeyValue.AppendColumn("Value",cellEditable,"text",2);
tvKeyValue.AppendColumn("Linked", new CellRendererText(), "text", 4); tvKeyValue.AppendColumn("Linked", new CellRendererText(), "text", 4);
tvKeyValue.AppendColumn("Created", new CellRendererText(), "text", 5); tvKeyValue.AppendColumn("Created", new CellRendererText(), "text", 5);
tvKeyValue.AppendColumn("Modified", new CellRendererText(), "text", 6); tvKeyValue.AppendColumn("Modified", new CellRendererText(), "text", 6);
tvKeyValue.RowActivated += new RowActivatedHandler(tvKeyValue_RowActivated); tvKeyValue.RowActivated += new RowActivatedHandler(tvKeyValue_RowActivated);
//tvKeyValue.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClickedKeyValue); //tvKeyValue.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClickedKeyValue);
entrySecretID.Text = selected; entrySecretID.Text = selected;
@ -330,11 +330,11 @@ public class MiCasa : Store
for( int i=0; i< keys.Length; i++ ) for( int i=0; i< keys.Length; i++ )
{ {
Secret secret = ss.GetSecret(selected); Secret secret = ss.GetSecret(selected);
Hashtable ht = secret.GetLinkedKeys(keys[i]); Hashtable ht = secret.GetLinkedKeys(keys[i]);
DateTime dtCreated = secret.GetCreateTimeForKey(keys[i]); DateTime dtCreated = secret.GetCreateTimeForKey(keys[i]);
DateTime dtModified = secret.GetModifiedTimeForKey(keys[i]); DateTime dtModified = secret.GetModifiedTimeForKey(keys[i]);
if (ht != null && ht.Count > 0) if (ht != null && ht.Count > 0)
@ -350,17 +350,17 @@ public class MiCasa : Store
"********", "********",
false, false,
"Yes", "Yes",
dtCreated.ToShortDateString() + " " + dtCreated.ToShortTimeString(), dtCreated.ToShortDateString() + " " + dtCreated.ToShortTimeString(),
dtModified.ToShortDateString() + " " + dtModified.ToShortTimeString()); dtModified.ToShortDateString() + " " + dtModified.ToShortTimeString());
} }
else else
{ {
tsKeyValue.AppendValues(keys[i], tsKeyValue.AppendValues(keys[i],
values[i], values[i],
"********", "********",
false, false,
"No", "No",
dtCreated.ToShortDateString() + " " + dtCreated.ToShortTimeString(), dtCreated.ToShortDateString() + " " + dtCreated.ToShortTimeString(),
dtModified.ToShortDateString() + " " + dtModified.ToShortTimeString()); dtModified.ToShortDateString() + " " + dtModified.ToShortTimeString());
} }
} }
@ -540,52 +540,52 @@ public class MiCasa : Store
/// </summary> /// </summary>
public void on_cbuttonShowPassword_toggled(object obj, EventArgs args) public void on_cbuttonShowPassword_toggled(object obj, EventArgs args)
{ {
TreeViewColumn tvCol; TreeViewColumn tvCol;
if (tvKeyValue.Model.IterNChildren() > 0) if (tvKeyValue.Model.IterNChildren() > 0)
{ {
if ((true == cbuttonShowPassword.Active) if ((true == cbuttonShowPassword.Active)
&& (CommonGUI.GetRememberMPUntil().CompareTo(DateTime.Now) > 0)) && (CommonGUI.GetRememberMPUntil().CompareTo(DateTime.Now) > 0))
{ {
// set and start the timer if needed // set and start the timer if needed
TimeSpan ts = CommonGUI.GetRememberMPUntil().Subtract(DateTime.Now); TimeSpan ts = CommonGUI.GetRememberMPUntil().Subtract(DateTime.Now);
m_iRememberSeconds = ts.Seconds; m_iRememberSeconds = ts.Seconds;
StartRememberTimer(); StartRememberTimer();
// display the values // display the values
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1)); tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 1); tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
tvKeyValue.InsertColumn(tvCol, 1); tvKeyValue.InsertColumn(tvCol, 1);
tvKeyValue.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClickedKeyValue); tvKeyValue.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClickedKeyValue);
} }
else if (true == cbuttonShowPassword.Active) else if (true == cbuttonShowPassword.Active)
{ {
// prompt user for MasterPassword // prompt user for MasterPassword
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogLogin", null); Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogLogin", null);
gxmlTemp.Autoconnect(this); gxmlTemp.Autoconnect(this);
dialogLogin.TransientFor = dialogManageSecret; dialogLogin.TransientFor = dialogManageSecret;
label86.Text = "Enter your Master Password to view values"; label86.Text = "Enter your Master Password to view values";
entryMasterPassword3.Text = ""; entryMasterPassword3.Text = "";
entryMasterPassword3.HasFocus = true; entryMasterPassword3.HasFocus = true;
label88.Hide(); label88.Hide();
entryMasterPassword4.Hide(); entryMasterPassword4.Hide();
labelRememberFor.Visible = true; labelRememberFor.Visible = true;
labelSeconds.Visible = true; labelSeconds.Visible = true;
spinbuttonRememberFor.Visible = true; spinbuttonRememberFor.Visible = true;
spinbuttonRememberFor.Text = m_config.GetConfigSetting(CommonGUI.REMEMBER_SETTING, m_sRememberFor); spinbuttonRememberFor.Text = m_config.GetConfigSetting(CommonGUI.REMEMBER_SETTING, m_sRememberFor);
dialogLogin.Show(); dialogLogin.Show();
} }
else else
{ {
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1)); tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2); tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
tvKeyValue.InsertColumn(tvCol, 1); tvKeyValue.InsertColumn(tvCol, 1);
tvKeyValue.ButtonReleaseEvent -= (OnRightClickedKeyValue); tvKeyValue.ButtonReleaseEvent -= (OnRightClickedKeyValue);
} }
} }
} }
@ -597,18 +597,18 @@ public class MiCasa : Store
if( 0 == miCASA.SetMasterPassword(0, entryMasterPassword3.Text) ) if( 0 == miCASA.SetMasterPassword(0, entryMasterPassword3.Text) )
{ {
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1)); tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 1); tvCol = new TreeViewColumn("Value", cellEditable, "text", 1);
tvKeyValue.InsertColumn(tvCol, 1); tvKeyValue.InsertColumn(tvCol, 1);
tvKeyValue.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClickedKeyValue); tvKeyValue.ButtonReleaseEvent += new ButtonReleaseEventHandler(OnRightClickedKeyValue);
// get seconds to remember // get seconds to remember
m_sRememberFor = spinbuttonRememberFor.Text; m_sRememberFor = spinbuttonRememberFor.Text;
if (m_sRememberFor != null) if (m_sRememberFor != null)
{ {
DateTime dtNow = DateTime.Now; DateTime dtNow = DateTime.Now;
m_iRememberSeconds = int.Parse(m_sRememberFor); m_iRememberSeconds = int.Parse(m_sRememberFor);
CommonGUI.SetRememberMPUntil(dtNow.AddSeconds(m_iRememberSeconds)); CommonGUI.SetRememberMPUntil(dtNow.AddSeconds(m_iRememberSeconds));
} }
// save off remember time if user changed it // save off remember time if user changed it
@ -619,9 +619,9 @@ public class MiCasa : Store
m_config.WriteConfig(); m_config.WriteConfig();
} }
dialogLogin.Destroy(); dialogLogin.Destroy();
if (m_iRememberSeconds > 0) if (m_iRememberSeconds > 0)
StartRememberTimer(); StartRememberTimer();
} }
else else
@ -651,38 +651,38 @@ public class MiCasa : Store
cbuttonShowPassword.Active = false; cbuttonShowPassword.Active = false;
dialogLogin.Destroy(); dialogLogin.Destroy();
args.RetVal = true; args.RetVal = true;
} }
private bool bTimerActive = false; private bool bTimerActive = false;
public void StartRememberTimer() public void StartRememberTimer()
{ {
if (!bTimerActive) if (!bTimerActive)
{ {
GLib.Timeout.Add ((uint)(m_iRememberSeconds * 1000), new GLib.TimeoutHandler (update_gui)); GLib.Timeout.Add ((uint)(m_iRememberSeconds * 1000), new GLib.TimeoutHandler (update_gui));
bTimerActive = true; bTimerActive = true;
} }
} }
private bool update_gui() private bool update_gui()
{ {
TreeViewColumn tvCol; TreeViewColumn tvCol;
try try
{ {
tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1)); tvKeyValue.RemoveColumn(tvKeyValue.GetColumn(1));
tvCol = new TreeViewColumn("Value", cellEditable, "text", 2); tvCol = new TreeViewColumn("Value", cellEditable, "text", 2);
tvKeyValue.InsertColumn(tvCol, 1); tvKeyValue.InsertColumn(tvCol, 1);
cbuttonShowPassword.Active = false; cbuttonShowPassword.Active = false;
tvKeyValue.ButtonReleaseEvent -= (OnRightClickedKeyValue); tvKeyValue.ButtonReleaseEvent -= (OnRightClickedKeyValue);
} }
catch (Exception e) catch (Exception e)
{ {
//Console.WriteLine(e.ToString()); //Console.WriteLine(e.ToString());
} }
bTimerActive = false; bTimerActive = false;
return false; return false;
} }
public void on_entryMasterPassword3_activate(object obj, EventArgs args) public void on_entryMasterPassword3_activate(object obj, EventArgs args)
{ {
@ -1019,7 +1019,7 @@ public class MiCasa : Store
if (selected.StartsWith("SS_CredSet")) if (selected.StartsWith("SS_CredSet"))
selected = selected.Substring(11); selected = selected.Substring(11);
saKeys = (string[]) model.GetValue(iter, 1); saKeys = (string[]) model.GetValue(iter, 1);
saValues = (string[]) model.GetValue(iter, 2); saValues = (string[]) model.GetValue(iter, 2);
CopySecret cs = new CopySecret(selected, saKeys, saValues); CopySecret cs = new CopySecret(selected, saKeys, saValues);
@ -1031,13 +1031,17 @@ public class MiCasa : Store
public void on_helpbuttonLinkKeys_clicked(object obj, EventArgs args) public void on_helpbuttonLinkKeys_clicked(object obj, EventArgs args)
{ {
Common.ShowHelpUrl("LinkingSecrets.htm"); Common.ShowHelpUrl("LinkingSecrets.htm");
} }
internal void FindAndReplaceValues() internal void FindAndReplaceValues()
{ {
FindAndReplace fr = new FindAndReplace(this, tvSecretIDMiCasa.Model, tsSecretIDMiCasa); CommonGUI cg = new CommonGUI();
fr.ShowDialog(); if (cg.VerifyMasterPasswordWithUser())
{
FindAndReplace fr = new FindAndReplace(this, tvSecretIDMiCasa.Model, tsSecretIDMiCasa);
fr.ShowDialog();
}
} }
///####################################################################### ///#######################################################################
@ -1380,140 +1384,140 @@ public class MiCasa : Store
{ {
md.Destroy(); md.Destroy();
} }
} }
// handlers for keyvalue context menu // handlers for keyvalue context menu
public void OnRightClickedKeyValue(object obj, ButtonReleaseEventArgs args) public void OnRightClickedKeyValue(object obj, ButtonReleaseEventArgs args)
{ {
Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - BEGIN"); Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - BEGIN");
if (3 == args.Event.Button) if (3 == args.Event.Button)
{ {
try try
{ {
Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - Context menu opened."); Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - Context menu opened.");
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "menuRightClickKeyValue", null); Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "menuRightClickKeyValue", null);
gxmlTemp.Autoconnect(this); gxmlTemp.Autoconnect(this);
menuRightClickKeyValue.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime); menuRightClickKeyValue.Popup(null, null, null, IntPtr.Zero, 3, Gtk.Global.CurrentEventTime);
} }
catch (Exception exp) catch (Exception exp)
{ {
Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - EXCEPTION:" + exp.ToString()); Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - EXCEPTION:" + exp.ToString());
} }
} }
Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - BEGIN"); Logger.DbgLog("GUI:MiCasa.OnRightClickedKeyValue() - BEGIN");
} }
private void on_menuItemLinkKey_activate(object o, EventArgs args) private void on_menuItemLinkKey_activate(object o, EventArgs args)
{ {
// display link dialog // display link dialog
tvKeyValue_RowActivated(o, null); tvKeyValue_RowActivated(o, null);
} }
private void on_menuItemDecodeValue_activate(object o, EventArgs args) private void on_menuItemDecodeValue_activate(object o, EventArgs args)
{ {
// get selected key/value // get selected key/value
// display decode window // display decode window
TreeModel model; TreeModel model;
TreeIter iter; TreeIter iter;
string selected=null; string selected=null;
string value = null; string value = null;
if (tvKeyValue.Selection.GetSelected(out model, out iter)) if (tvKeyValue.Selection.GetSelected(out model, out iter))
{ {
selected = (string)model.GetValue(iter, 0); selected = (string)model.GetValue(iter, 0);
value = (string)model.GetValue(iter, 1); value = (string)model.GetValue(iter, 1);
if ((value == null) || (value.Length <1)) if ((value == null) || (value.Length <1))
{ {
// read value from store // read value from store
SecretStore ss = GetMiCasaStore(); SecretStore ss = GetMiCasaStore();
Secret secret = ss.GetSecret(entrySecretID.Text); Secret secret = ss.GetSecret(entrySecretID.Text);
value = secret.GetKeyValue(selected); value = secret.GetKeyValue(selected);
// strip of header data // strip of header data
byte[] baValue = System.Text.Encoding.ASCII.GetBytes(value); byte[] baValue = System.Text.Encoding.ASCII.GetBytes(value);
byte[] baTarget = new byte[baValue.Length - 16]; byte[] baTarget = new byte[baValue.Length - 16];
Array.Copy(baValue, 13, baTarget, 0, baValue.Length - 16); Array.Copy(baValue, 13, baTarget, 0, baValue.Length - 16);
try try
{ {
baValue = Convert.FromBase64String(System.Text.Encoding.ASCII.GetString(baTarget)); baValue = Convert.FromBase64String(System.Text.Encoding.ASCII.GetString(baTarget));
value = System.Text.Encoding.ASCII.GetString(baValue); value = System.Text.Encoding.ASCII.GetString(baValue);
} }
catch (Exception e) catch (Exception e)
{ {
value = e.ToString(); value = e.ToString();
} }
} }
if (selected != null && selected.Length > 0) if (selected != null && selected.Length > 0)
{ {
Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogDecode", null); Glade.XML gxmlTemp = new Glade.XML(Common.GladeFile, "dialogDecode", null);
gxmlTemp.Autoconnect(this); gxmlTemp.Autoconnect(this);
// display values // display values
textviewClear.Buffer.Text = value; textviewClear.Buffer.Text = value;
// hook up button handlers // hook up button handlers
bttnDecode.Clicked += new EventHandler(bttnDecode_Clicked); bttnDecode.Clicked += new EventHandler(bttnDecode_Clicked);
bttnEncode.Clicked += new EventHandler(bttnEncode_Clicked); bttnEncode.Clicked += new EventHandler(bttnEncode_Clicked);
bttnExpand.Clicked += new EventHandler(bttnExpand_Clicked); bttnExpand.Clicked += new EventHandler(bttnExpand_Clicked);
dialogDecode.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("dialogManageSecret"); dialogDecode.TransientFor = (Gtk.Window)CasaMain.gxmlMain.GetWidget("dialogManageSecret");
dialogDecode.Modal = true; dialogDecode.Modal = true;
dialogDecode.Show(); dialogDecode.Show();
} }
} }
} }
void bttnExpand_Clicked(object sender, EventArgs e) void bttnExpand_Clicked(object sender, EventArgs e)
{ {
bttnDecode.Visible = bttnDecode.Visible =
bttnEncode.Visible = bttnEncode.Visible =
textviewEncoded.Visible = textviewEncoded.Visible =
scrolledwindowEncoded.Visible = !bttnDecode.Visible; scrolledwindowEncoded.Visible = !bttnDecode.Visible;
if (bttnDecode.Visible) if (bttnDecode.Visible)
{ {
bttnExpand.Label = " << "; bttnExpand.Label = " << ";
} }
else else
{ {
bttnExpand.Label = " >> "; bttnExpand.Label = " >> ";
} }
} }
void bttnEncode_Clicked(object sender, EventArgs e) void bttnEncode_Clicked(object sender, EventArgs e)
{ {
string sClear = textviewClear.Buffer.Text.Trim(); string sClear = textviewClear.Buffer.Text.Trim();
if (sClear.Length > 0) if (sClear.Length > 0)
{ {
textviewEncoded.Buffer.Clear(); textviewEncoded.Buffer.Clear();
textviewEncoded.Buffer.Text = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(sClear)); textviewEncoded.Buffer.Text = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(sClear));
} }
} }
void bttnDecode_Clicked(object sender, EventArgs e) void bttnDecode_Clicked(object sender, EventArgs e)
{ {
string sEncoded = textviewEncoded.Buffer.Text.Trim(); string sEncoded = textviewEncoded.Buffer.Text.Trim();
if (sEncoded.Length > 0) if (sEncoded.Length > 0)
{ {
char[] array = sEncoded.ToCharArray(); char[] array = sEncoded.ToCharArray();
byte[] bytes = Convert.FromBase64CharArray(array, 0, array.Length); byte[] bytes = Convert.FromBase64CharArray(array, 0, array.Length);
textviewClear.Buffer.Text = System.Text.Encoding.ASCII.GetString(bytes); textviewClear.Buffer.Text = System.Text.Encoding.ASCII.GetString(bytes);
} }
} }
private void on_bttnCloseDecode_clicked(object sender, EventArgs args) private void on_bttnCloseDecode_clicked(object sender, EventArgs args)
{ {
if (dialogDecode != null) if (dialogDecode != null)
{ {
dialogDecode.Destroy(); dialogDecode.Destroy();
} }
} }
} }
} }
///################################################################## ///##################################################################