// Copyright (C) 2002, Wayne Diamond ?>

SUB XorString(sStr$, BYVAL xKey&) '// by Wayne Diamond REGISTER I AS DWORD FOR I = 1 TO LEN(sStr$): MID$(sStr$,i,1) = CHR$(ASC(MID$(sStr$,i,1)) XOR xKey&): NEXT END SUB SUB XorString(sStr$, BYVAL xKey&) '// by Wayne Diamond #REGISTER NONE LOCAL straddr AS STRING PTR, dwLen AS DWORD straddr = STRPTR(sStr$) dwLen = LEN(sStr$) ! mov ecx, dwLen ; ecx = str length ! mov esi, straddr ; esi = straddr ! mov edi, straddr ; edi = straddr (we're overwriting) ! cld ; ensure direction flag is clear Cipher: '; start of loop ! lodsb ; al = next byte from str ! xor al, xKey& ; encrypt al ! stosb ; store al in dec$ at edi ! loop Cipher ; dec ecx, loop if ecx != 0 ! mov straddr, edx ; dec$ = @edx END SUB SUB XorString(sStr$, BYVAL xKey&) '// by Lothar Pink #REGISTER NONE DIM I AS LONG, lsPtr AS LONG, myStrLen& lsPtr = STRPTR(sStr$) myStrLen& = LEN(sStr$) ! mov eax, lsPtr ; string descriptor in eax ! cmp eax, 0 ; no str data ! je EndXorLoop ; jump to EndXorLoop ! mov ecx, myStrLen& ; ecx = Len(sStr) BeginXorLoop: ! mov dl, [eax] ; move 1 byte to dl (low byte of edx) ! xor dl, xKey& ; xor that byte (DL) ! mov [eax], dl ; move DL back to eax ! dec ecx ; decrement ecx ! cmp ecx, 0 ; detect end of string ! je EndXorLoop ; jump to EndXorLoop ! inc eax ; increase eax ! jmp BeginXorLoop ; jump to BeginXorLoop EndXorLoop: END SUB