예제 #1
0
 private void DecryptCBC()
 {
     try
     {
         string input = txt_input.Text.Replace(" ", string.Empty).ToLower().Trim();
         if (IsValidHex(input) && input.Length % 16 == 0)
         {
             DESCBC descbc = new DESCBC(key, iv);
             descbc.Create();
             descbc.DecryptCBC(input);
             rtb_main.Text   = $"Input:   {input.ToUpper()}\nOutput:  {descbc.CbcDecryptText}";
             lbl_output.Text = "";
         }
         else
         {
             if (!IsValidHex(input))
             {
                 MessageBox.Show("Input must be 64-bit Hexadecimal format", "Error",
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             txt_input.Text = input.PadLeft((16 * ((input.Length / 16) + 1)), '0').ToUpper();
             DecryptCBC();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Keys or IV not saved!", "Error",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
예제 #2
0
        public void TestMethod1()
        {
            DESCBC dcbc = new DESCBC("AABB09182736CCDD", "AAAAAAAAAAAAAAAA");

            dcbc.Create();
            dcbc.EncryptCBC("0000000000000000ABCDEF1234567890");
            var x = dcbc.CbcCipherText;
            //DES.DES a = new DES.DES("ffffffffffffffff");
            //DESModules m = new DESModules();
            //a.Create();
            //string res = a.Encrypt("1234567890abcdef");


            //int[] l = m.HexStringToIntArray("5a78e394");
            //int[] cpy = l;
            //int[] r = m.HexStringToIntArray("4a1210f6");
            //int[] temp = new int[32];
            //m.Function(r, ref temp, a.roundKeys[2]);
            //string testkey = m.BinArrayToHex(a.roundKeys[2]);
            //int[] t2 = m.XOR(cpy, temp);
            //string test = m.BinArrayToHex(t2);
        }