Ejemplo n.º 1
0
        public void GivenANode_WhenEncrypt_ValueShouldBeEncryptedCorrectly(Element element)
        {
            var processor    = new EncryptProcessor(TestEncryptKey);
            var node         = CreateNodeFromElement(element);
            var originalText = node.Value?.ToString();

            processor.Process(node);

            // Here we only check the cipher text can be correctly decrypted since we are using a random IV during encryption
            Assert.Equal(originalText, DecryptText(node.Value?.ToString()));
        }
        private Dictionary <string, IAnonymizerProcessor> CreateTestProcessors()
        {
            KeepProcessor       keepProcessor       = new KeepProcessor();
            RedactProcessor     redactProcessor     = new RedactProcessor(false, false, false, null);
            DateShiftProcessor  dateShiftProcessor  = new DateShiftProcessor("123", "123", false);
            CryptoHashProcessor cryptoHashProcessor = new CryptoHashProcessor("123");
            EncryptProcessor    encryptProcessor    = new EncryptProcessor("1234567890123456");
            SubstituteProcessor substituteProcessor = new SubstituteProcessor();
            PerturbProcessor    perturbProcessor    = new PerturbProcessor();
            Dictionary <string, IAnonymizerProcessor> processors = new Dictionary <string, IAnonymizerProcessor>()
            {
                { "KEEP", keepProcessor },
                { "REDACT", redactProcessor },
                { "DATESHIFT", dateShiftProcessor },
                { "CRYPTOHASH", cryptoHashProcessor },
                { "ENCRYPT", encryptProcessor },
                { "SUBSTITUTE", substituteProcessor },
                { "PERTURB", perturbProcessor }
            };

            return(processors);
        }
        public EncryptProcessorUnitTests()
        {
            var encryptObj = "{\"encryptKey\": \"123456781234567812345678\"}";

            Processor = new EncryptProcessor(JObject.Parse(encryptObj));
        }