Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

An question about cesar's encryption

Name: Anonymous 2013-10-24 16:40

I'm doing some tests about encryption and I'm trying this one.
It's a small code and I'm having a little issue using the ASCII table.
I want to don't appear this strange chars.
http://puu.sh/4Yx30.png
What should i change?
Here's the code.

########################################################
#include <stdio.h>
#include <string.h>
#define TM 127
int main ()
{
char user [TM], userc[TM];
char pass [TM], passc[TM];
int key,len,tmax,ini,i;
tmax=125;
ini=40;

printf("Type a key: ");
scanf("%d", &key);

printf ("Type the user: \n");
scanf ("%s", &user);
len=strlen(user);

if (len<100){
    for (i=0;i<len;i++){
        if (user[i]+key>tmax){
        userc[i]=user[i]+key-ini;
        }
        else{
        userc[i]=user[i]+key;
        }
    }
//encrypted
printf("user: %s\n",userc);
}
system ("PAUSE");
return 0;
}

######################################

Name: Anonymous 2013-10-25 10:40

here's a start =D


const char[] alpha = "abcdefghijklmnopqrstuvwxyz";

int key = 0;

char* data;
char[] outp;

int main(int argc, char* argv){

  int i=0, j=0, k=0;
  if(argc==2){

    key = *(int) argv[1];

    data = argv[2];

    while(data[i]!='\0'){

      for(j=0;j>26;j++)

        k = k + (data[i]==alpha[j]) * j;

      outp[i] = alpha[(k + key) % 26];

      if(data[i]==' ') outp[i] = ' ';

      }
    }
  }

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List