"ncf" <[EMAIL PROTECTED]> writes:
> As I fail to see how an array could be used in this (my own
> stupidity?), would you have any such example? 

How's this (untested):

    state = [A,B,C,D,E,F,G,H]
    magic = [0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5, 
             0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5, 0xD807AA98 ]

    def P(state, i, magic):
       a,b,c,d,e,f,g,h = state[i:] + state[:i]
       temp1 = h + S3(e) + F1(e,f,g) + K + x
       temp2 = S2(a) + F0(a,b,c)
       # d += temp1; h = temp1 + temp2
       state[(i+3)%8] += temp1; state[(i+7)%8] = temp1 + temp2

    for i in range(9):
       P(state, i, W, magic)

Actually this isn't so good.  You have to be careful about arithmetic
overflow, i.e. do all the additions mod 2**32, so you don't get Python
longs.  I'll leave that as an exercise.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to