samedi 28 novembre 2015

How to find the answer to a XOR hash if I have the key & one number

I have a little routine that makes up a cumulative XOR hash. It's as if it is a savings account which gets bigger, cumulatively daily.. but in this sense we're saying the answer is being generated cumulatively and the key is always present.

I have taken a string of chars

pseudo code:

char H[10] = { "ABCDEFGHI", "\0" };

and I used 9 32-bit numeric keys to hash them in XOR encryption.

I did it like this:

for (i;i<10;i++)
    bitset<32> K ^= H[i] ^ NUMKEY[i];

Now this makes it impervious without the calculus plotting I did (see what I did there?) So K is an accumulation of calculus points, which are completely predictable according to calculus.

as far as I know, to undo it, I do

for (i;i<10;i++) {
    X=0;
    X ^= K ^ NUMKEY[i];
}

Is there other math involved? I think I have to take that X and do a little K - X to find the true derivative.

Here's the current routine I have for it. But I'm not getting what I'm looking for.

for_each (std::istreambuf_iterator<char>(in), \
    std::istreambuf_iterator<char>(), \
    [&] (long x) {
    t=s_nop(t,0);
    cred.push_back(t);
    alpha = static_cast<long>(cred[size]);
    delta = static_cast<long>(x);
    lambda ^= (alpha ^ delta);
    size++;
});

for (;i<=bn-1;i++) {
    alpha =  static_cast<unsigned long>(cred[bn-1-i]);
    delta ^= alpha ^ lambda;
    long hash1 = abs(lambda.to_ulong() + alpha.to_ulong() - 1);
    lambda = static_cast<unsigned long>(hash1);
    btrace.push_back(delta.to_ulong());
    delta=0;
}

Please have a safe and Merry Christmas. Thank you in advance!

Aucun commentaire:

Enregistrer un commentaire