Thanks.
Sheepishly provided (as I should have done in my first post) is the code
that makes Access hiccup:
This is the primary code of the function that is called from a form. A
string to encrypt (sInput) is passed:
' if the string length is not a multiple of 8
' then pad with spaces
While (Len(sInput) And &H7)
sInput = sInput & Chr(32)
Wend
While i <= Len(sInput)
' VB long data type is a 32 bit integer (4 byte)
' put numeric representation of first 4 characters of the input
string in p1D
i = i + 1
p1D = Asc(Mid(sInput, i, 1))
i = i + 1
p1D = p1D Or lShift(Asc(Mid(sInput, i, 1)), 8)
i = i + 1
p1D = p1D Or lShift(Asc(Mid(sInput, i, 1)), 16)
i = i + 1
p1D = p1D Or lShift(Asc(Mid(sInput, i, 1)), 24)
' put numeric representation of next 4 characters of the input
string in p2D
i = i + 1
p2D = Asc(Mid(sInput, i, 1))
i = i + 1
p2D = p2D Or lShift(Asc(Mid(sInput, i, 1)), 8)
i = i + 1
p2D = p2D Or lShift(Asc(Mid(sInput, i, 1)), 16)
i = i + 1
p2D = p2D Or lShift(Asc(Mid(sInput, i, 1)), 24)
aReturn = encipher(p1D, p2D, aKey) ' aKey is an arrray of long
previously
'
populated
'
aReturn is an array of long
sOutput = sOutput & "" & decToHex(aReturn(1)) & decToHex(aReturn(2))
Wend
The encipher function looks like this:
sum = 0
n = 32 ' number of iterations
temp(0) = -1 ' temp is an array of Long
temp(1) = p1
temp(2) = p2
While n > 0
i1 = lShift(temp(2), 4) ' rShift and lShift are utility
functions
i2 = rShift(temp(2), 5, False) ' that perform a right and left
bitwise shift
i3 = i1 Xor i2 ' <-- this is where we bomb on
virtually all inputs
i4 = temp(2) Xor sum
i5 = k(sum And 3)
temp(1) = temp(1) + i3 + i4 + i5
sum = sum + delta ' delta is a constant with value &H9E3779B9
temp(2) = temp(2) + ((lShift(temp(1), 4) Xor rShift(temp(1), 5,
False)) + (temp(1) Xor sum) + k(rShift(sum, 11, False) And 3))
n = n - 1
Wend
encipher = temp
On test data, such as a single character 't', I get the following values
passed INTO the encrypt function:
p1 = 538976372
p2 = 538976288
The intermediate values i1 and i2 calculated are:
i1 = 8623620608
i2 = 21559051
the value of i1 XOR i2 results in an overflow
This is a convoluted, but I hope someone can decipher it and come up with a
reason.
Thanks much -
Dave