Function Encriptar(Encriptar As Boolean, Textto As String) As String
const C1 = 11111
const C2 = 22222
dim Clave as UInt16 = &hFFFF
dim mbSource as MemoryBlock = Textto
dim mbResult as new MemoryBlock( mbSource.Size )
dim lastIndex as integer = mbSource.Size - 1
for byteIndex as integer = 0 to lastIndex
mbResult.Byte( byteIndex ) = mbSource.Byte( byteIndex ) Xor Bitwise.ShiftRight( Clave, 8 )
if Encriptar then
Clave = ( mbResult.Byte( byteIndex ) + Clave ) * C1 + C2 // Encriptar
else
Clave = ( mbSource.Byte( byteIndex ) + Clave ) * C1 + C2 // Desencriptar
end if
next
return mbResult
End Function