... other declarations >... >DECLARE @counter INT >DECLARE @curChar BINARY(1) >DECLARE @curKey BINARY(1) >SET @counter = 1 >WHILE @counter <= LEN( @bytData) >BEGIN > SET @curChar = SUBSTRING( @bytData, @counter, 1) > SET @curKey = SUBSTRING( @bytKey, @counter, 1) > IF @counter % 2 = 0 > SET @curChar = @curChar | (@curKey + @KEY_OFFSET) > ELSE > SET @curChar = @curChar | (@curKey - @KEY_OFFSET) > SET @bytData = CONVERT( VARBINARY, STUFF( @bytData, @counter, 1, @curChar)) > SET @counter = @counter + 1 >END >...>
>>Dim KEY_OFFSET As Long >>Dim bytKey() As Byte >>Dim bytData() As Byte >>Dim lNum As Long >> >>'...Set values for the various variables, then: >> >>For lNum = LBound(bytData) To UBound(bytData) >> If lNum Mod 2 Then >> bytData(lNum) = bytData(lNum) Xor (bytKey(lNum) + KEY_OFFSET) >> Else >> bytData(lNum) = bytData(lNum) Xor (bytKey(lNum) - KEY_OFFSET) >> End If >>Next lNum>>I can ( or at least I think I can ) get most of the entities translated, i.e. the arrays bounds, Mod, and Xor I can translate. I am using T-SQL varbinary() for the equivalent VB byte arrays and the specific problem I am wrestling with is how to "replace" bits ( bytes? ) in the varbinary() variable like is done with the
>> bytData(lNum) = bytData(lNum) Xor (bytKey(lNum) + KEY_OFFSET)>>VB statement.