Ejemplo n.º 1
0
        private void Mapping(TableEntrie[] Data)
        {
            PanelSetting = new Point(0, 0);
            foreach (TableEntrie item in Data)
            {
                switch (item.Key)
                {
                case "SentinelPort": SentinelPort = UInt16.Parse(item.Value); break;

                case "NodeAPI.IPAddress": API.IPAddress = ECB.Decrypt(item.Value, KeyEncrypt); break;

                case "NodeAPI.Port": API.Port = ECB.Decrypt(item.Value, KeyEncrypt); break;

                case "MSSQL.Name": MSSQL.Name = ECB.Decrypt(item.Value, KeyEncrypt); break;

                case "MSSQL.ServerName": MSSQL.ServerName = ECB.Decrypt(item.Value, KeyEncrypt); break;

                case "MSSQL.Username": MSSQL.Username = ECB.Decrypt(item.Value, KeyEncrypt); break;

                case "MSSQL.Password": MSSQL.Password = ECB.Decrypt(item.Value, KeyEncrypt); break;

                case "PanelConfig.X": PanelSetting.X = Double.Parse(ECB.Decrypt(item.Value, KeyEncrypt)); break;

                case "PanelConfig.Y": PanelSetting.Y = Double.Parse(ECB.Decrypt(item.Value, KeyEncrypt)); break;
                }
            }
        }
Ejemplo n.º 2
0
        public void Decrypt_Decrypts10Bytes_Decrypted()
        {
            byte[] bytes = { 6, 6, 6, 6, 6, 6, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
            var    blockEncryptorMock = MockRepository.GenerateMock <ICipher>();

            blockEncryptorMock.Expect(m => m.BlockSize).Return(16);
            blockEncryptorMock.Expect(m => m.Decrypt(bytes)).Return(bytes.Reverse().ToArray());
            //blockEncryptorMock.Expect(m => m.DecryptBlock(padding)).Return(padding);

            ECB          encryptor = new ECB(blockEncryptorMock, new PKCS7Padding());
            MemoryStream input     = new MemoryStream(bytes);
            MemoryStream output    = new MemoryStream();

            encryptor.Decrypt(input, output);
            CollectionAssert.AreEqual(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }, output.GetBuffer().SubArray(0, 10));
        }