Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

[Duvida] Criiptografia cifra-de-cesar

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    C# [Duvida] Criiptografia cifra-de-cesar

    Bom pessoal curso Sistemas de informação estou no 2º semestre,mas estou com um professor péssimo em linguagem estruturada (C#) ,então tenho que estudar sozinho,mas tenho um trabalho pra entregar que esta muito em cima da hora, e estou com problema para fazer esse programa descriptografar,gostaria de saber se alguem pode far uma força ae,bom o codigo para criptografar ficou assim:


    Código:
    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace Caesar
    {
        class Program
        {
            static void Main(string[] args)
            {
                char[] storeletter = new char[26] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'q', 'x', 'y', 'z' };
                int Knumber = 3;
                int lettere = 0;
                string temp = string.Empty;
                string Enterletter = string.Empty;
                Console.WriteLine("Digite a palavra à ser criptografada: ");
                Enterletter = Console.ReadLine();
    
                for (int i = 0; i <= Enterletter.Length - 1; i++)
                {
                    for (int j = 0; j <= storeletter.Length - 1; j++)
                    {
                        if (Enterletter[i] == storeletter[j])
                        {
                            lettere = j;
                            int c = (lettere + Knumber) % 26;
                            temp += storeletter[c].ToString();
                        }
                    }
                }
                Console.WriteLine(temp);
                Console.Read();
            }
        }
    }
    Similar Threads
X
Working...
X