Exemple #1
0
        public async Task <ActionResult <string> > AceptarLogin(Execute.Command command,
                                                                [FromRoute] int?enc)
        {
            if (enc != null)
            {
                command.Buffer = _zCryptography.GetCipherText(command.Buffer);
            }
            command.RemoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress;

            string response = await _mediator.Send(command);

            return(response);
        }
        public void Plain_text_to_cipher_and_visceversa_works_well()
        {
            var plainText = "1234";

            ZCryptographySettings zCriptographySettings = new ZCryptographySettings();

            zCriptographySettings.Key = "$B&E)H@McQfTjWnZr4u7x!A%C*F-JaNd";
            zCriptographySettings.IV  = "z%C*F-JaNdRgUkXp";

            /*
             * zCriptographySettings.Key = "$B&E)H@McQfTjWnZr4u7x!A%C*F-JaNd";
             * zCriptographySettings.IV = "z%C*F-JaNdRgUkXp";
             */
            IOptions <ZCryptographySettings> settingsOptions = Options.Create(zCriptographySettings);

            ZCryptography zCriptography     = new ZCryptography(settingsOptions);
            var           cipherText        = zCriptography.GetCipherText(plainText);
            var           plainTextReversed = zCriptography.GetPlainText(cipherText);

            Assert.Equal(plainText, plainTextReversed);
        }