[ create a new paste ] login | about

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

GiM - D, pasted on May 20:
/* Michal 'GiM' Spadlinski
 * dear children, don't do this at home :>
 */
import tango.io.Stdout;

/* this is evil rip from the code
 * I even was to lazy to translate it
 * to 32 bits
 */
ushort crc16(char *p)
{
    asm {
        mov ESI, p[EBP];
        push    BX;
        mov     CX, -1;
        mov     DX, CX;
        mov     DI, 5;
        mainloop:
            xor     AX, AX;
            xor     BX, BX;
            lodsb;
            xor     AL, CL;
            mov     CL, CH;
            mov     CH, DL;
            mov     DL, DH;
            mov     DH, 8;
            do8bits:
                shr     BX, 1;
                rcr     AX, 1;
                jnc nimaxora;
                    xor     AX, 0x8320;
                    xor     BX, 0xEDB8;
                nimaxora:
                dec     DH;
            jnz do8bits;
            xor     CX, AX;
            xor     DX, BX;
            dec     DI;
        jnz mainloop;

        not     DX;
        not     CX;
        pop     BX;
        mov     AX, DX;
        ror     AX, CL;
        add     AX, CX;
    }
}
void main()
{
    const static char[] zbior = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.1234567890";
    char[][] names = ["UUENC", "PKLIT", "LZEXE", "NDD.E", "DIET.", "SCAND", "SD.EX", "SPEED",
                        "DEFRA", "TLINK", "WLINK", "LINK.", "DPMI1", "DPMI3", "RTM.E", "RTM32"];
    char[5] tmp;
    char[][ushort] blip;
    int[ushort] blop;
    ushort crc;


    foreach (name; names)
    {   
        blip[crc16(name.ptr)] = name;
        blop[crc16(name.ptr)] = 1;
    }
    foreach (a; zbior)
    {   
        tmp[0] = a;
        foreach (b; zbior)
        {   
            tmp[1] = b;
            foreach (c; zbior)
            {   
                tmp[2] = c;
                foreach (d; zbior)
                {   
                    tmp[3] = d;
                    foreach (e; zbior)
                    {   
                        tmp[4] = e;
                        crc = crc16(tmp.ptr);
                        auto p = crc in blip;
                        if (p !is null)
                            blop[crc]++;
                    }
                }
            }
        }
        Stdout (".").flush;
    }
    foreach (x, val; blop)
    {   
        Stdout (blip[x], val).newline;
    }
}


Output:
1
2
.....
Timeout


Create a new paste based on this one


Comments: