Ejemplo n.º 1
0
        public void CheckIfCaesarCipherWorksCorrectly(string input, int code, string encryptedInput, Mode mode)
        {
            var service = new CipherService();
            var dto     = new CipherCaesarDto
            {
                Input = input,
                Code  = code
            };
            string actual = service.ExecCaesarCipher(mode, dto);

            Assert.AreEqual(encryptedInput, actual);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetCaesarCipherDecode([FromQuery] CipherCaesarDto dto)
        {
            string result = _cipherService.ExecCaesarCipher(Mode.Decrypt, dto);

            return(Ok(result));
        }
Ejemplo n.º 3
0
 public string ExecCaesarCipher(Mode mode, CipherCaesarDto dto)
 {
     return(mode == Mode.Encrypt
         ? new string(dto.Input.Select(ch => Encrypt(ch, dto.Code)).ToArray())
         : new string(dto.Input.Select(ch => Encrypt(ch, 26 - dto.Code)).ToArray()));
 }