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

Pages: 1-

/gorp/ challenge #2: serialme

Name: Anonymous 2008-02-29 10:43

/* /gorp/ challenge #2: serialme
   2008-02-29

   Requirements: c99 compiler, ASCII or compatible character set.
   Example: gcc serialme.c -O2 -Wall -Wextra -std=c99 -oserialme

   It's source so people can't whine it doesn't run on their SPARC with Plan9.

   Everyone is allowed to use this in any way. */

#include <stdio.h>
#include <stdint.h>

#define BUFSIZE 8

static int hexdigit_to_int(char hex)
{
    if(hex >= '0' && hex <= '9')
        return hex - '0';

    if(hex >= 'A' && hex <= 'F')
        return hex - 'A' + 10;

    return -1;
}

int main(int argc, char** argv)
{
    unsigned buffer[BUFSIZE];

    if(argc != 2)
    {
        puts("Usage: serialme [serial]");
        return 0;
    }

    char *input = argv[1];
    for(unsigned i = 0; i < BUFSIZE; i++)
    {
        int low, high;
        high = hexdigit_to_int(*input++);
        if(high == -1)
            return 1;
        low  = hexdigit_to_int(*input++);
        if(low  == -1)
            return 1;
        buffer[i] = (high << 4) | low;
    }
    if(*input)
        return 1;

    const unsigned checkvalues[BUFSIZE][BUFSIZE+1] =
        {{195, 162, 208,   7,  39,  60,  55, 112, 121261},
         {177,  37, 168, 214, 104,  81, 120, 111, 116729},
         { 49,  39, 221, 134, 241, 211, 110, 104, 152301},
         { 65,  56, 253,  18,  94, 116,  57, 183, 115139},
         {152,  54, 137,   5, 150, 182, 195, 179, 148075},
         {219, 100, 130, 195, 125, 197, 244, 184, 175270},
         {123, 223,  21, 203, 140,  26, 112,  84, 116269},
         {171, 163, 212,  44,  20, 125, 214,  84, 139951}};

    for(unsigned i = 0; i < BUFSIZE; i++)
    {
        unsigned sum = 0;
        for(unsigned j = 0; j < BUFSIZE; j++)
            sum += checkvalues[i][j] * buffer[j];
        if(sum != checkvalues[i][BUFSIZE])
            return 1;
    }

    printf("Congrats, please go to http://ln-s.net/");
    putchar(buffer[0] ^ buffer[4]);
    putchar(buffer[1] ^ buffer[5]);
    putchar(buffer[2] ^ buffer[6]);
    putchar(buffer[3] ^ buffer[7]);
    puts(" for your prize.");

    return 0;
}

Name: Anonymous 2008-02-29 10:53

sage time

Name: Anonymous 2008-02-29 10:55

gcc sageme.c -O2 -Wall -Wextra -std=c99 -osageme

Name: Anonymous 2008-02-29 11:09


static int hexdigit_to_int(char hex)
{
    if(hex >= '0' && hex <= '9')
        return hex - '0';

    if(hex >= 'A' && hex <= 'F')
        return hex - 'A' + 10;

    return -1;
}

Fail.

int hexdigit_to_int(int c) {
  const char hex[] = "0123456789abcdef";
  return isxdigit(c) ? strchr(hex, tolower(c)) - hex : -1;
}

 

Name: Anonymous 2008-02-29 12:17

printf("Congrats, please go to http://ln-s.net/");
puts(" for your prize.");


Is it loli?

Name: Anonymous 2008-02-29 12:25


#!/bin/bash
faggot=0
while [  $faggot -lt 99999999 ]; do
        ./a.out $faggot
        let faggot=faggot+1
done

Name: Anonymous 2008-02-29 12:27

A WINRAR IS ME

Name: Anonymous 2008-02-29 15:19

/gorp/ is that way --> http://rechan.da.ru/gorp/

Name: Anonymous 2008-02-29 15:48

>>4
OMG OPTIMIZED!!!!111

Name: Anonymous 2008-02-29 16:37

>>7
Back to /b/, please.

Name: Anonymous 2008-02-29 17:21

http://ln-s.net/1c7D
you made me install matlab for this?

Name: Anonymous 2008-02-29 17:40

>>11
Everyone's smiling at you

Name: Anonymous 2008-02-29 19:57

>>11
oh rickroll. that was like 3 months ago.

Name: Anonymous 2008-03-01 7:45

>>11
You mean you don't have Mathematica?

Name: Anonymous 2008-03-01 7:46

>>1-14
Back to /gorp/, please.

Name: Anonymous 2008-03-01 8:42

>>15
This may surprise you, but /gorp/ fucking sucks.

Name: Anonymous 2008-03-01 9:30

>>16
Just like /prog/.

Name: Anonymous 2008-03-01 10:49

>>17
You are clearly unaware of /sci/

Name: Anonymous 2009-07-12 6:57

system("pause");    моего I   I Language not be \|

Name: Anonymous 2011-02-03 2:17

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