From: antony.clements@optusnet.com.au   
      
   i eralilse what i said i'm trying to do is quite vague. the purpose of the   
   code is the core of a stream cipher where they key is defined as   
      
   key = var1 xor var2 xor var3 where var3 is (2147483647 * rnd). what happens   
   next is cipherbyte = chr((messagebyte xor key) mod 256)   
      
   >> Call CopyMemory(var1, var1 Xor var2, 8)   
   >> Call CopyMemory(var1, var1 Xor var3, 8)   
      
   does actually work as written.   
      
   the problem is that var1 and var2 are always the same constant no matter   
   what the source is.   
      
   "Dean Earley" wrote in message   
   news:45d438c9$0$22115$db0fefd9@news.zen.co.uk...   
   > Antony Clements wrote:   
   >> i modified the code after i posted this, it no longer throws up an error   
   >> but it still doesn't work correctly.   
   >>   
   >> dim var1 var2 and var3 as long   
   >>   
   >> ReDim IVbytearray(0 To 7)   
   >> ReDim IVbytearray2(0 To 7)   
   >   
   > These are redundant as they are replaced in the next block.   
   >   
   >> bytearray() = Mid(stream1, b, 8)   
   >> bytearray2() = Mid(stream2, c, 8) 'a messagebox here proves that at this   
   >> point, the data held in bytearray() is different than the data held in   
   >> bytearray2()   
   >   
   > This copies a UNICODE string into the byte array.   
   > This will be 16 bytes, every other one being a null character.   
   >   
   > If you want each character as an item in the array, then you want:   
   > bytearray = StrConv(string, vbFromUnicode)   
   >   
   >> var1 = bytearray()   
   >> var2 = bytearray2() 'this is where the problem is as var2 returns the   
   >> same value as var1 even though the value in bytearray() is different to   
   >> the value in bytearray2().   
   >   
   > From the code below, you can't join them up like this.   
   > You will need to do the arithmetic manually (shifting and adding) or   
   > copymemory from the byte array to a long.   
   > Bear in mind that you can only fit 4 bytes in a long...   
   >   
   >> Call CopyMemory(var1, var1 Xor var2, 8)   
   >> Call CopyMemory(var1, var1 Xor var3, 8)   
   >   
   > Be VERY careful as longs are still only 4 bytes.   
   > you WILL be corrupting memory with this code.   
   >   
   >> now here is the problem. even though the data source for bytearray() and   
   >> bytearray2() are different, for some reason or other they both have the   
   >> same value. var2 needs to be a value from the second data source. i hope   
   >> this is a clear indication of what i am trying to do.   
   >   
   > It still doesn't explain what you have and what results you want at the   
   > end...   
   >   
   > --   
   > Dean Earley (dean.earley@icode.co.uk)   
   > i-Catcher Development Team   
   >   
   > iCode Systems   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|