Thread: xoring

  1. #1
    Registered User Sekti's Avatar
    Join Date
    Feb 2002
    Posts
    163

    xoring

    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.
    +++
    ++
    + Sekti
    ++
    +++

  2. #2
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    Go through each character and XOR it with the string and uh... use the key over again for all leftover sets of characters of string...?

    I don't know, that's a pretty simple encryption...

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    Use the key twice. Or extend the key.

    >string=string^key;

    Isn't this going wrong? The variables string and key are addresses. For encryption you need a loop and xor each character.

  4. #4
    Banned borko_b's Avatar
    Join Date
    Jun 2002
    Location
    Well... I live in Bulgaria :)
    Posts
    100
    Code:
    #define KLEN 10
    #defien VLEN 200
    
    
    
    char val[2002];
    char key[322];
    
    char *pv = val;
    char *pk = key;
    
    while(*pv) {
        *pv ^= *pk;
        if(*pk) 
            pk++;
        else     
            pk = key;
        pv++;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fast XORing chars
    By zxcv in forum C Programming
    Replies: 9
    Last Post: 05-30-2008, 02:15 AM