Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

XOR Cipher

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

  • Font Size
    #1

    C / C++ XOR Cipher

    Ola Pessoal, venho aqui a vocês mostrar um programa bem simples com uma cifra bem simples tmb :
    Código:
    #include <stdio.h>
    
    #define MAXLINE 1000
    
    int strlen(char string[]);
    int genkey(int integer);
    char xor_string(char message[], char key[]);
    
    main(){
     char subkey[MAXLINE];
     char message[MAXLINE];
     printf("\tXOR Cipher\nInsert the message to be ciphred:\n");
     scanf("%s", message);
     int len = strlen(message) - 1;
     sprintf(subkey, "%d", genkey(len));
     xor_string(message, subkey);
        
    }
    
    int genkey(int i){
     int key = srand(i);
        return key;
    }
    
    char xor_string(char mes[], char kiy[]){
     int i = 0;
     int n;
     char total[MAXLINE];
     while(mes[i] != '\0' && kiy[i] != '\0'){
            total[i] = mes[i] ^ kiy[i];
      i++;
     }
     printf("The Cipher is:%s\n", total);
    
    }
    
    int strlen(char s[]){
     int i;
     for(i = 0; s[i] != '\0'; i++){
     ;
     }
     return i;
    
    }
    Last edited by Nickguitar.dll; 15-12-2014, 21:55. Motivo: Correção de código.
    sigpic


    Patati Patacula, la vem o pato para ver o que Ha!!

  • Font Size
    #2
    Boa jovi.
    Yes, I am a criminal. My crime is that of curiosity. My crime is
    that of judging people by what they say and think, not what they look like.
    My crime is that of outsmarting you, something that you will never forgive me
    for.

    I am a hacker, and this is my manifesto. You may stop this individual,
    but you can't stop us all... after all, we're all alike.

    Comment

    X
    Working...
    X