(ins, outs)
return s
Encrypt a byte stream read from the GWBASIC tokenised format.
Encrypt a byte stream read from the GWBASIC tokenised format.
Encrypt a byte stream read from the GWBASIC tokenised format .
def protect(ins, outs):
    """Encrypt a byte stream read from the GWBASIC tokenised format."""
    index = 0
    nxt = ins.read(1)
    while nxt != b'':
        s = nxt
        c = ord(s)
        # inverse Kocher's algorithm:
        c -= 13 - (index % 13)
        c ^= KEY1 [index % 13]
        c ^= KEY2 [index % 11]
        c += 11 - (index % 11)
        outs.write(int2byte(c % 256))
        index = (index+1) % (13*11)
        nxt = ins.read(1)
    # return last char read
    return s
def protect ( ins , outs ) : index = 0 nxt = ins . read ( 1 ) while nxt != b'' : s = nxt c = ord ( s ) # inverse Kocher's algorithm: c -= 13 - ( index % 13 ) c ^= KEY1 [ index % 13 ] c ^= KEY2 [ index % 11 ] c += 11 - ( index % 11 ) outs . write ( int2byte ( c % 256 ) ) index = ( index + 1 ) % ( 13 * 11 ) nxt = ins . read ( 1 ) # return last char read return s