Criptografia de Cesar
Publicado por Perfil removido (última atualização em 20/01/2010)
[ Hits: 14.953 ]
Bem, estava lendo um artigo do Prof. Elgio aqui no VOL que tem como título: "Introdução a Criptografia". Para quem quiser conferir: http://www.vivaolinux.com.br/artigo/Introducao-a-criptografia/
Nele vi uma simples criptografia que é chamada de "Cifra de César". Resolvi botar a mesma em prática. Segue o script.
Abraço.
// cripto_cesar.c // // Copyright 2010 Orlando Xavier <ox@orlandoxavier.org> // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, // MA 02110-1301, USA. #include <stdio.h> #include <stdlib.h> #include <string.h> void encrypt(void); void uncrypt(void); void lowercase(char string[]); void clear(void) { system("clear"); } void getch(void) { system("read key"); } int main(int argc, char** argv) { int menu = 0; do { printf("\n\nEnter para Continuar: \n"); getch(); clear(); printf("+----------------------------+\n"); printf("|;.<<,y7= Cesar-Crypto +;-,~^|\n"); printf("+--------------+-------------+\n"); printf("|&.6,+---------+--------+`~{,|\n"); printf("|*[3,| (1) - Encrypt |,.çz|\n"); printf("|;5m.+---------+--------+[k/;|\n"); printf("|,'.;+---------+--------+.7.,|\n"); printf("|}1>i| (2) - uncrypt |'^,>|\n"); printf("|^f,;+---------+--------+,j.'|\n"); printf("|&];.+---------+--------+x~};|\n"); printf("|.4-a| (3) - Exit |'.,!|\n"); printf("+----+------------------+----+\n"); printf("Escolha uma opcao: "); scanf("%d",&menu); switch (menu) { case 1: encrypt(); break; case 2: uncrypt(); break; } } while (menu != 3); return(0); } void encrypt(void) { char string[255]; int i = 0; clear(); printf("Entre com a palavra: "); gets(string); gets(string); lowercase(string); for (; string[i] != '{FONTE}'; i++) { if (string[i] == 'z') string[i] = 'c'; else if (string[i] == 'y') string[i] = 'b'; else if (string[i] == 'x') string[i] = 'a'; else string[i] = string[i] + 3; } printf("Resultado >> "); for (i = 0; string[i] != '{FONTE}'; i++) { printf("%c",string[i]); } } void uncrypt(void) { char string[255]; int i = 0; clear(); printf("Entre com a sequencia: "); gets(string); gets(string); lowercase(string); for (; string[i] != '{FONTE}'; i++) { if (string[i] == 'c') string[i] = 'z'; else if (string[i] == 'b') string[i] = 'y'; else if (string[i] == 'a') string[i] = 'x'; else string[i] = string[i] - 3; } printf("Resultado >> "); for (i = 0; string[i] != '{FONTE}'; i++) { printf("%c",string[i]); } } void lowercase(char string[]) { int i = 0; while (string[i]) { string[i] = tolower(string[i]); i++; } return; }
Atenção a quem posta conteúdo de dicas, scripts e tal (6)
Como Configurar um Túnel SSH Reverso para Acessar Sua Máquina Local a Partir de uma Máquina Remota
Configuração para desligamento automatizado de Computadores em um Ambiente Comercial
O mínimo que você precisa saber sobre o terminal (parte 2)
O mínimo que você precisa saber sobre o terminal (parte 1)
Como iniciar uma máquina virtual do VirtualBox automaticamente no boot do LUbuntu 18 LTS
Flatpak: remover runtimes não usados e pacotes
Mudar o gerenciador de login (GDM para SDDM e vice-versa) - parte 2
Como deixar as abas do Firefox mais fininhas
Mudar o gerenciador de login (GDM para SDDM)
"Tentando" fazer com que programas rodem no Wayland e no X11
UTILIZAÇÃO SISTEMA OPERACIONAL - LINUX (0)
Falha ao carregar drivers [RESOLVIDO] (2)
Formatar NVM Express 1.3 de forma segura por completo (4)
Problema ao usar monitor externo via USB-C/Display... no Ubuntu 24 (1)
[Python] Automação de scan de vulnerabilidades
[Python] Script para analise de superficie de ataque
[Shell Script] Novo script para redimensionar, rotacionar, converter e espelhar arquivos de imagem
[Shell Script] Iniciador de DOOM (DSDA-DOOM, Doom Retro ou Woof!)
[Shell Script] Script para adicionar bordas às imagens de uma pasta