Ejemplo n.º 1
0
        public void Encrypt_Encrypts10Bytes_Encrypted()
        {
            byte[] bytes              = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            byte[] padding            = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 6, 6, 6, 6, 6, 6 };
            var    blockEncryptorMock = MockRepository.GenerateMock <ICipher>();

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

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

            encryptor.Encrypt(input, output);
            CollectionAssert.AreEqual(new byte[] { 6, 6, 6, 6, 6, 6, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 },
                                      output.GetBuffer().SubArray(0, 16));
        }
Ejemplo n.º 2
0
        public void Save()
        {
            TypeSFO FileConfig = new TypeSFO();

            FileConfig.Param("SentinelPort", SentinelPort);

            FileConfig.Param("NodeAPI.IPAddress", ECB.Encrypt(API.IPAddress, KeyEncrypt));
            FileConfig.Param("NodeAPI.Port", ECB.Encrypt(API.Port, KeyEncrypt));
            FileConfig.Param("MSSQL.Name", ECB.Encrypt(MSSQL.Name, KeyEncrypt));
            FileConfig.Param("MSSQL.ServerName", ECB.Encrypt(MSSQL.ServerName, KeyEncrypt));
            FileConfig.Param("MSSQL.Username", ECB.Encrypt(MSSQL.Username, KeyEncrypt));
            FileConfig.Param("MSSQL.Password", ECB.Encrypt(MSSQL.Password, KeyEncrypt));

            FileConfig.Param("PanelConfig.X", ECB.Encrypt(PanelSetting.X.ToString(), KeyEncrypt));
            FileConfig.Param("PanelConfig.Y", ECB.Encrypt(PanelSetting.Y.ToString(), KeyEncrypt));


            FileConfig.SaveAs(Module.TravoxSentinel + Module.File_Config);
        }