int arc4_test()
{
    byte cipher[16];
    byte plain[16];

    const char* keys[] = 
    {           
        "\x01\x23\x45\x67\x89\xab\xcd\xef",
        "\x01\x23\x45\x67\x89\xab\xcd\xef",
        "\x00\x00\x00\x00\x00\x00\x00\x00",
        "\xef\x01\x23\x45"
    };

    testVector test_arc4[] =
    {
        testVector("\x01\x23\x45\x67\x89\xab\xcd\xef",
                   "\x75\xb7\x87\x80\x99\xe0\xc5\x96"),
        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
                   "\x74\x94\xc2\xe7\x10\x4b\x08\x79"),
        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
                   "\xde\x18\x89\x41\xa3\x37\x5d\x3a"),
        testVector("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
                   "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf\xbd\x61")
    };


    int times( sizeof(test_arc4) / sizeof(testVector) );
    for (int i = 0; i < times; ++i) {
        ARC4::Encryption enc;
        ARC4::Decryption dec;

        enc.SetKey((byte*)keys[i], (word32)strlen(keys[i]));
        dec.SetKey((byte*)keys[i], (word32)strlen(keys[i]));

        enc.Process(cipher, test_arc4[i].input_, test_arc4[i].outLen_);
        dec.Process(plain,  cipher, test_arc4[i].outLen_);

        if (memcmp(plain, test_arc4[i].input_, test_arc4[i].outLen_))
            return -30 - i;

        if (memcmp(cipher, test_arc4[i].output_, test_arc4[i].outLen_))
            return -40 - i;
    }

    return 0;
}
int arc4_test()
{
    byte cipher[16];
    byte plain[16];

    const char* keys[] = 
    {           
        "\x01\x23\x45\x67\x89\xab\xcd\xef",
        "\x01\x23\x45\x67\x89\xab\xcd\xef",
        "\x00\x00\x00\x00\x00\x00\x00\x00",
        "\xef\x01\x23\x45"
    };

    testVector test_arc4[] =
    {
        testVector("\x01\x23\x45\x67\x89\xab\xcd\xef",
                   "\x75\xb7\x87\x80\x99\xe0\xc5\x96"),
        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
                   "\x74\x94\xc2\xe7\x10\x4b\x08\x79"),
        testVector("\x00\x00\x00\x00\x00\x00\x00\x00",
                   "\xde\x18\x89\x41\xa3\x37\x5d\x3a"),
        testVector("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
                   "\xd6\xa1\x41\xa7\xec\x3c\x38\xdf\xbd\x61")
    };


    int times( sizeof(test_arc4) / sizeof(testVector) );
    for (int i = 0; i < times; ++i) {
        ARC4::Encryption enc;
        ARC4::Decryption dec;

        enc.SetKey((byte*)keys[i], (word32)strlen(keys[i]));
        dec.SetKey((byte*)keys[i], (word32)strlen(keys[i]));

        enc.Process(cipher, test_arc4[i].input_, test_arc4[i].outLen_);
        dec.Process(plain,  cipher, test_arc4[i].outLen_);

        if (memcmp(plain, test_arc4[i].input_, test_arc4[i].outLen_))
            return -30 - i;

        if (memcmp(cipher, test_arc4[i].output_, test_arc4[i].outLen_))
            return -40 - i;
    }

    return 0;
}