[ create a new paste ] login | about

Link: http://codepad.org/yIP3EhjH    [ raw code | output | fork ]

C, pasted on Sep 15:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
 
typedef enum {false, true} bool;
 
#define KEY_LIMIT 0xFFFFFFFF
#define DATA_LEN 9
 
int main()
{
    char cdata[] = {0x61, 0xFA, 0x1E, 0x51, 0x7C, 0x94, 0x24, 0xD0, 0xD7};
    char ddata[DATA_LEN] = {0};
 
    bool invalidChars = false;
    for(int keyValue = 0; keyValue < KEY_LIMIT; keyValue++)
    {
        for(int wordIndex = 0; wordIndex < DATA_LEN; wordIndex++)
        {
            ddata[wordIndex] = cdata[wordIndex] ^ keyValue; 
            if(!isalnum(ddata[wordIndex]) && !isspace(ddata[wordIndex]))
            {
                invalidChars = true;
                break;
            }    
        }
 
        if(!invalidChars)
        {
            printf("Data: %s - Key: 0x%X\n", ddata, keyValue);
        }
 
        memset(ddata, DATA_LEN, 0);
        invalidChars = false;
    }
}


Output:
1
2
3
In function 'main':
Line 17: error: 'for' loop initial declaration used outside C99 mode
Line 19: error: 'for' loop initial declaration used outside C99 mode


Create a new paste based on this one


Comments: