private void addKeyButton_Click(object sender, RoutedEventArgs e) { if (newKeyTextBox.Text != "") { AddKey?.Invoke(sender, newKeyTextBox.Text); newKeyTextBox.Text = ""; } }
/// <summary> /// Notifies to add a key. /// </summary> /// <param name="alias">alias alias to notify</param> /// <param name="keys">keys that need approval</param> /// <param name="deviceMetadata">device metadata of the keys</param> /// <returns>status of the notification</returns> public Task <NotifyStatus> NotifyAddKey(Alias alias, IList <Key> keys, DeviceMetadata deviceMetadata) { var unauthenticated = ClientFactory.Unauthenticated(channel); var addKey = new AddKey { DeviceMetadata = deviceMetadata }; addKey.Keys.Add(keys); return(unauthenticated.NotifyAddKey(alias, addKey)); }
/// <summary> /// This method run when add button cliecked /// </summary> private void addBT_Click(object sender, EventArgs e) { if (filePath != string.Empty) { AddKey addKey = new AddKey(filePath); addKey.Show(); } else { MessageBox.Show("First load or create keys file !", "Error status", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Notifies subscribed devices that a key should be added. /// </summary> /// <param name="alias">alias of the member</param> /// <param name="addKey">AddKey payload to be sent</param> /// <returns></returns> public Task <NotifyStatus> NotifyAddKey(Alias alias, AddKey addKey) { var request = new NotifyRequest { Alias = alias, Body = new NotifyBody { AddKey = addKey } }; return(gateway.NotifyAsync(request) .ToTask(response => response.Status)); }
private void OnClick(object sender, EventArgs e) { int modify; lList = new List <AddKey>(); Keyboard kb = new Keyboard(lList, this.Location, false); if ((kb.ShowDialog() != DialogResult.OK) || (lList.Count == 0)) { return; } regKey = lList[0]; ID_registBox.Text = regKey.key.ToString() + ((regKey.isShift == 1) ? " + Shift" : "") + ((regKey.isCtrl == 1) ? " + Ctrl" : "") + ((regKey.isAlt == 1) ? " + Alt" : ""); }
/// <summary> /// Notifies subscribed devices that a token should be created and endorsed. /// </summary> /// <param name="tokenRequestId">the token request ID to send</param> /// <param name="keys">keys to be added</param> /// <param name="deviceMetadata">device metadata of the keys</param> /// <param name="receiptContact">optional receipt contact to send</param> /// <returns>notify result of the notification request</returns> public Task <NotifyResult> NotifyCreateAndEndorseToken( string tokenRequestId, IList <Key> keys, DeviceMetadata deviceMetadata, ReceiptContact receiptContact) { UnauthenticatedClient unauthenticated = ClientFactory.Unauthenticated(channel); var addKey = new AddKey { DeviceMetadata = deviceMetadata }; addKey.Keys.Add(keys); return(unauthenticated.NotifyCreateAndEndorseToken( tokenRequestId, addKey, receiptContact)); }
private void treeAdd_Click(object sender, EventArgs e) { try { AddKey addKey = new AddKey(treeViewRegistery.SelectedNode.FullPath); DialogResult result = addKey.ShowDialog(); if (result == DialogResult.OK) { thLoadKeys = new Thread(LoadKeys); thLoadKeys.Start(); } else { MessageBox.Show("عملیات توسط کاربر لغو شد.", "افزودن", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception) { MessageBox.Show("نرم افزار قادر به ایجاد کلید در کلید انتخاب شده نیست.", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Notifies subscribed devices that a token should be created and endorsed. /// </summary> /// <param name = "tokenRequestId">the token request ID to send</param> /// <param name = "addKey">optional add key payload to send</param> /// <param name = "receiptContact">optional receipt contact to send</param> /// <returns>notify result of the notification request</returns> public Task <NotifyResult> NotifyCreateAndEndorseToken( string tokenRequestId, AddKey addKey, ReceiptContact receiptContact) { var request = new TriggerCreateAndEndorseTokenNotificationRequest { TokenRequestId = tokenRequestId }; if (addKey != null) { request.AddKey = addKey; } if (receiptContact != null) { request.Contact = receiptContact; } return(gateway.TriggerCreateAndEndorseTokenNotificationAsync(request) .ToTask(response => NotifyResult.Create(response.NotificationId, response.Status))); }
private void OnClick(object sender, EventArgs e) { if (keyData.SelectedRows == null) { return; } AddKey key; foreach (DataGridViewRow selKey in keyData.SelectedRows) { key = new AddKey(); key.key = (Keys)selKey.Cells[4].Value; key.isShift = Convert.ToBoolean(selKey.Cells[1].Value) == true ? 1 : 0; key.isCtrl = Convert.ToBoolean(selKey.Cells[2].Value) == true ? 1 : 0; key.isAlt = Convert.ToBoolean(selKey.Cells[3].Value) == true ? 1 : 0; lKey.Add(key); } this.DialogResult = DialogResult.OK; this.Close(); }
public void Add(K _key, V _newValue) { if (isValueNull(_newValue)) { throw new NullNotAllowedException("Null not allowed as value"); } List <V> tempValues; if (map.TryGetValue(_key, out tempValues)) { AddValue?.Invoke(_newValue); tempValues.Add(_newValue); } else { AddKey?.Invoke(_key); tempValues = new List <V>(); tempValues.Add(_newValue); map.Add(_key, tempValues); } }
private void newLoginToolStripMenuItem_Click(object sender, EventArgs e) { AddKey addKeyForm = new AddKey(); addKeyForm.parent = this; addKeyForm.Show(); }
private byte[] ProcessEncrypt(byte[] byteInput, string password) { if (password.Length != blockSize) { throw new Exception("Password is not 128bit long"); } var result = new List <byte>(); //We will divide the byteInput into Block of 16 chars var blockIteration = (int)Math.Ceiling((byteInput.Length * 1.0) / blockSize); var currentByteBlock = new byte[4, 4]; var cbcBlock = new byte[4, 4]; BlockFill(cbcBlock, 0); var substitute = new Substitution(); var addKey = new AddKey(substitute, password); var mixColumn = new MixColumns(); var shiftRow = new ShiftRow(); for (var blockCount = 0; blockCount < blockIteration; blockCount++) { var blockStart = blockCount * blockSize; //COnvert to a blockArray of 4x4 for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { currentByteBlock[j, i] = (byte)(cbcBlock[j, i] ^ byteInput[blockStart + i * 4 + j]); } } LogEngine.LogBytes(currentByteBlock, "Current Block"); addKey.AddRoundKey(0, currentByteBlock); LogEngine.LogBytes(currentByteBlock, "Current Block , Round" + 0); for (int rnd = 1; rnd < Nr; rnd++) { substitute.ByteSubstitute(currentByteBlock); LogEngine.LogBytes(currentByteBlock, "Substitute Byte"); shiftRow.ByteShift(currentByteBlock); LogEngine.LogBytes(currentByteBlock, "Shift Row"); mixColumn.ApplyColumn(currentByteBlock); LogEngine.LogBytes(currentByteBlock, "Mix Column"); addKey.AddRoundKey(rnd, currentByteBlock); LogEngine.LogBytes(currentByteBlock, "Current Block , Round" + rnd); } substitute.ByteSubstitute(currentByteBlock); shiftRow.ByteShift(currentByteBlock); addKey.AddRoundKey(Nr, currentByteBlock); LogEngine.LogBytes(currentByteBlock, "Current Block , Round" + Nr); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { result.Add(currentByteBlock[j, i]); } } BlockCopy(currentByteBlock, cbcBlock); } addKey.Dispose(); return(result.ToArray()); }
private byte[] ProcessDecrypt(byte[] byteInput, string password) { if (password.Length != blockSize) { throw new Exception("Password is not 128bit long"); } var result = new List <byte>(); //We will divide the byteInput into Block of 16 chars var blockIteration = (int)Math.Ceiling((byteInput.Length * 1.0) / blockSize); var currentByteBlock = new byte[4, 4]; var cbcBlock = new byte[4, 4]; BlockFill(cbcBlock, 0); var substitute = new Substitution(); var addKey = new AddKey(substitute, password); var mixColumn = new MixColumns(); var shiftRow = new ShiftRow(); for (var blockCount = 0; blockCount < blockIteration; blockCount++) { var blockStart = blockCount * blockSize; var cipherCBC = new byte[4, 4]; //COnvert to a blockArray of 4x4 for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { currentByteBlock[j, i] = byteInput[blockStart + i * 4 + j]; cipherCBC[j, i] = currentByteBlock[j, i]; } } LogEngine.LogBytes(currentByteBlock, "Current Block"); addKey.AddRoundKey(Nr, currentByteBlock); shiftRow.InvByteShift(currentByteBlock); substitute.InvByteSub(currentByteBlock); for (int rnd = Nr - 1; rnd > 0; rnd--) { addKey.AddRoundKey(rnd, currentByteBlock); mixColumn.InvApplyColumn(currentByteBlock); shiftRow.InvByteShift(currentByteBlock); substitute.InvByteSub(currentByteBlock); } addKey.AddRoundKey(0, currentByteBlock); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { result.Add((byte)(cbcBlock[j, i] ^ currentByteBlock[j, i])); } } //Copy this stage Cypher as next stage CBC BlockCopy(cipherCBC, cbcBlock); } addKey.Dispose(); return(result.ToArray()); }