how do i encrypt things that are say 10 characters long with a key that is 5. like this

char string[10];
char key[5];

string=string^key;

only encrypts half of string.