mardi 29 octobre 2019

syntax error during implementation of RC4 algorithm

I am trying to modify implementation RC4 algorithm in python that i found online and i am getting a syntax error for using a if loop in place of while loop can anybody tell me why is that?

def PRGA(S):

i = 0
j = 0
if i==0 & j==0:    # here it was originally while True:, so I changed it to if statement
    i = (i + 1) % 256
    j = (j + S[i]) % 256

    S[i], S[j] = S[j], S[i]  # swap values
    K = S[(S[i] + S[j]) % 256
    print ('K')    # and here it was yield K
else:
    print ('error')

Aucun commentaire:

Enregistrer un commentaire