I'm adapting some B4x code to create a OTP/2FA code and I'm struggeling with the datatypes.
This B4R code gives the correct values (compared to the B4x code at the bottom) except of the Bit.Or commands. PT is always wrong (=doesn't change due to the or operations). p1 - p4 are correct.
I tried other datatypes but that did not work. Any ideas?
B4R
B4J:
This B4R code gives the correct values (compared to the B4x code at the bottom) except of the Bit.Or commands. PT is always wrong (=doesn't change due to the or operations). p1 - p4 are correct.
I tried other datatypes but that did not work. Any ideas?
B4R
B4X:
Dim Offs As UInt= Bit.And(hmacbytessha1(19),15)
Dim p1,p2,p3,p4 As ULong
Dim pt As ULong
Dim OTP As ULong
p1=Bit.ShiftLeft(Bit.And(hmacbytessha1(Offs+0),127),24)
Log("p1: ",p1)
p2=Bit.ShiftLeft(Bit.And(hmacbytessha1(Offs+1),255),16)
Log("p1: ",p2)
p3=Bit.ShiftLeft(Bit.And(hmacbytessha1(Offs+2),255),8)
Log("p3: ",p3)
p4=Bit.And(hmacbytessha1(Offs+3),255)
Log("p4: ",p4)
pt=Bit.Or(p1,p2)
Log("pt1: ",p1)
pt=Bit.Or(pt,p3)
Log("pt2: ",p1)
pt=Bit.Or(pt,p4)
Log("pt3: ",p1)
B4J:
B4X:
Dim Offs As Int= Bit.And(b(19),15)
Dim OTP,p1,p2,p3,p4,pt As Int
p1=Bit.ShiftLeft(Bit.And(b(Offs+0),127),24)
Log("p1: " &p1)
p2=Bit.ShiftLeft(Bit.And(b(Offs+1),255),16)
Log("p2: " &p2)
p3=Bit.ShiftLeft(Bit.And(b(Offs+2),255),8)
Log("p3: " &p3)
p4=Bit.And(b(Offs+3),255)
Log("p4: " &p4)
pt=Bit.Or(p1,p2)
Log("pt1: " & pt)
pt=Bit.Or(pt,p3)
Log("pt2: " & pt)
OTP=Bit.Or(pt,p4) Mod Power(10,6)