Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *With L0v3 from @ov3rflow1 :P
- * */
- #include <stdio.h>
- #include <stdlib.h>
- void cesar();
- int selection();
- char * readBuffer();
- int main(int argc,char **argv){
- cesar();
- return 0x00;
- }
- void cesar(){
- char *password,*buffer=NULL;
- int i,keySum,action=0;
- printf("==ALGORITMO DE C3$4r==\n\n");
- action=selection();
- printf("\nBuffer:");
- buffer=readBuffer();
- printf("\nPassword: ");
- password=readBuffer();
- i=0;
- keySum=0;
- while((int)*(password+i)!=0){
- keySum+=(int)(*(password+i));
- i++;
- }
- keySum*=action;
- printf("Procediendo con el desplazamiento:%d\n",keySum);
- i=0;
- while((int)*(buffer+i)!=0){
- char tmp=((int)*(buffer+i))+keySum;
- printf("%c",tmp);
- i++;
- }
- }
- /*
- int selection(){
- int action=0;
- printf("Menu de opciones:\n\n");
- printf("\t1) cifrar\n");
- printf("\t2) descifrar\n");
- printf("\nElige una opcion: ");
- scanf("%d",&action);
- switch(action){
- case 1:
- action=1;
- break;
- case 2:
- action=-1;
- break;
- default:
- action=1;
- }
- return action;
- }
- */
- int selection(){
- char *buffer;
- printf("Menu de opciones:\n\n");
- printf("\t1) cifrar\n");
- printf("\t2) descifrar\n");
- printf("\nElige una opcion: ");
- buffer=readBuffer();
- switch(*(buffer+0)){
- case '1':
- return 1;
- case '2':
- return -1;
- default:
- return 1;
- }
- }
- /*
- char * readBuffer(){
- char **ptrStr=malloc(sizeof(char*)*1);
- char key;
- int len=0;
- *(ptrStr+0)=malloc(sizeof(char));
- char pacman;
- scanf("%c",&pacman);
- if((int)pacman!=10)
- key=pacman;
- else
- scanf("%c",&key);
- while((int)key!=10){
- *(*(ptrStr+0)+len)=key;
- scanf("%c",&key);
- len++;
- }
- char *retStr=*(ptrStr+0);
- return retStr;
- }
- char *readBuffer(){
- char pacman;
- char *buffer;
- scanf("%c",&pacman);
- buffer=malloc(sizeof(char)*31337);
- //scanf("%s",buffer);
- gets(buffer);
- return buffer;
- }
- */
- char *readBuffer(){
- char *buffer;
- buffer=malloc(sizeof(char)*31337);
- gets(buffer);
- return buffer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement