(ins, outs)
return int2byte(c % 256)
Decrypt a byte stream read from the GWBASIC ,P (read protected) format. This will allow it to be subsequently parsed.
Decrypt a byte stream read from the GWBASIC ,P (read protected) format. This will allow it to be subsequently parsed.
Decrypt a byte stream read from the GWBASIC P ( read protected ) format . This will allow it to be subsequently parsed .
def unprotect(ins, outs):
    """Decrypt a byte stream read from the GWBASIC ,P (read protected) format. This will allow it to be subsequently parsed."""
    index = 0
    s = ins.read(1)
    while s != b'':
        nxt = ins.read(1)
        # drop last char (EOF 0x1a)
        if nxt == b'':
            break
        c = ord(s)
        # Kocher's algorithm:
        c -= 11 - (index % 11)
        c ^= KEY1 [index % 13]
        c ^= KEY2 [index % 11]
        c += 13 - (index % 13)
        outs.write(int2byte(c % 256))
        index = (index+1) % (13*11)
        s = nxt
    # return last char written
    return int2byte(c % 256)
def unprotect ( ins , outs ) : index = 0 s = ins . read ( 1 ) while s != b'' : nxt = ins . read ( 1 ) # drop last char (EOF 0x1a) if nxt == b'' : break c = ord ( s ) # Kocher's algorithm: c -= 11 - ( index % 11 ) c ^= KEY1 [ index % 13 ] c ^= KEY2 [ index % 11 ] c += 13 - ( index % 13 ) outs . write ( int2byte ( c % 256 ) ) index = ( index + 1 ) % ( 13 * 11 ) s = nxt # return last char written return int2byte ( c % 256 )