Here is my control example:
Bascom with those code:
[code:1:c0c57f670a]
Dim Key(16) As Byte ' 128 bit key
Dim Msg(32) As Byte ' this need to be a multiple of 8
Dim B As Byte ' counter byte
Dim C As Byte
For B = 1 To 16 ' create a simple key and also fill the data
Key(b) = &H55
Next
Msg(1) = "5"
Msg(2) = "5"
Msg(3) = "5"
Msg(4) = "5"
Msg(5) = "5"
Msg(6) = "5"
Msg(7) = "5"
Msg(8) = "5"
Msg(9) = "5"
Msg(10) = "5"
Msg(11) = "5"
Msg(12) = "5"
Msg(13) = "5"
Msg(14) = "5"
Msg(15) = "5"
Msg(16) = "5"
Xteaencode Msg(1) , Key(1) , 16 ' encode the data
Print "Encrypted" ; ": " ;
For B = 1 To 16
Print Hex(msg(b)) ;
Next
Print
[/code:1:c0c57f670a]
Gives me this: Encrypted: D72F98668A1D56D8D72F98668A1D56D8
Ok, the B4A code using the same parameters:
[code:1:c0c57f670a]
Dim sData As String
Dim sKey As String
Dim Key(16) As Byte
Dim I As Int
For I = 0 To 15 Step 1
Key(I) = 0x55
Next
sKey = XT.ByteToString(Key)
sData = XT.Crypt("5555555555555555", sKey, False)
Log(sData)
[/code:1:c0c57f670a]
Gives me this: ecbfec734e5ea83eecbfec734e5ea83e
Thats the problem. If I run the same example using online internet XTEA scripts, I get the same result as B4A. Nothing ever equals BASCOM's version of XTEA. Why i dunno.
↧