I tried to encrypt using the same key and tekst in both B4 and C# but I obtain a different byte array in both
B4A:
B4X:
Sub Encrypt(dataToEncrypt As String)
Dim kg As KeyGenerator
Dim C As Cipher
Dim encrypted() As Byte
kg.Initialize("AES")
kg.KeyFromBytes("5TGB&YHN7UJM(IK<".GetBytes("UTF8"))
C.Initialize("AES/CBC/PKCS7Padding")
C.InitialisationVector = "!QAZ2WSX#EDC4RFV".GetBytes("UTF8")
encrypted = C.Encrypt(dataToEncrypt.GetBytes("UTF8"), kg.Key, False)
Dim foo(encrypted.Length) As Int
For lcv = 0 To encrypted.Length - 1
foo (lcv) = Bit.AND(0xFF, encrypted(lcv))
Next
End Sub
I compare the array foo with the dest array in C# code: