public void TestEncrypt2()
        {
            byte[] expected =
                ByteTool.Convert(
                    "04 30 9D 13 04 9C 7E D9 84 8B 33 C3 26 5C 1F 91 30 27 D3 56 B0 FD 81 36 50 3A EF 80 1C B9 25 D6 38 84 A7 07 45 FE E8 D7 01 83 A1 CE 04 79 9D 5F 9E 2F");
            OctetString engineId = new OctetString(ByteTool.Convert("80 00 1F 88 80  E9 63 00 00  D6 1F F4 49"));
            var         priv     = new TripleDESPrivacyProvider(new OctetString("passtest"),
                                                                new MD5AuthenticationProvider(new OctetString("testpass")));
            Scope scope = new Scope(engineId, OctetString.Empty,
                                    new GetRequestPdu(0x3A25,
                                                      new List <Variable> {
                new Variable(new ObjectIdentifier("1.3.6.1.2.1.1.3.0"))
            }));
            SecurityParameters parameters = new SecurityParameters(engineId, new Integer32(0x14), new Integer32(0x35),
                                                                   new OctetString("lexmark"), new OctetString(new byte[12]),
                                                                   new OctetString(ByteTool.Convert("00 00 00  01 44 2C A3 B5")));
            var       original = scope.GetData(VersionCode.V3);
            ISnmpData data     = priv.Encrypt(original, parameters);

            Assert.Equal(SnmpType.OctetString, data.TypeCode);
            //Assert.Equal(ByteTool.Convert(expected), ByteTool.Convert(data.ToBytes()));

            ISnmpData decrypted = priv.Decrypt(data, parameters);

            Assert.Equal(ByteTool.Convert(original.ToBytes()), ByteTool.Convert(decrypted.ToBytes()));
        }
        public void TestException()
        {
            var provider = new TripleDESPrivacyProvider(new OctetString("longlongago"),
                                                        new MD5AuthenticationProvider(new OctetString("verylonglongago")));

            Assert.Throws <ArgumentNullException>(() => new TripleDESPrivacyProvider(null, null));
            Assert.Throws <ArgumentNullException>(() => new TripleDESPrivacyProvider(OctetString.Empty, null));
            Assert.Throws <ArgumentNullException>(() => provider.Encrypt(null, null));
            Assert.Throws <ArgumentNullException>(() => provider.Encrypt(OctetString.Empty, null));

            {
                var exception = Assert.Throws <ArgumentException>(() =>
                                                                  provider.Encrypt(new Null(), SecurityParameters.Create(OctetString.Empty)));
                Assert.Equal($"Invalid data type.{Environment.NewLine}Parameter name: data", exception.Message);
            }

            Assert.Throws <ArgumentNullException>(() => provider.Decrypt(null, null));
            Assert.Throws <ArgumentNullException>(() => provider.Decrypt(OctetString.Empty, null));
            {
                var exception = Assert.Throws <ArgumentException>(() =>
                                                                  provider.Decrypt(new Null(), SecurityParameters.Create(OctetString.Empty)));
                Assert.Equal($"Cannot decrypt the scope data: Null.{Environment.NewLine}Parameter name: data", exception.Message);
            }
        }