Hi all
I've this code that runs in B4A:
In B4J fails in this line:
Log says:
What's wrong??
I've this code that runs in B4A:
B4X:
Sub Encrypt(DataToEncrypt As String) As String
Dim kg As KeyGenerator
Dim c As Cipher
Dim B64 As Base64
Dim bconv As ByteConverter
Dim data(0) As Byte
Dim iv(0) As Byte
iv = Array As Byte(11, 22, 33, 44, 55, 66, 77, 88) ' 16 bytes for AES
c.Initialize("DESEDE/CBC/PKCS5Padding")
c.InitialisationVector = iv
kg.Initialize("DESEDE")
kg.KeyFromBytes(bconv.StringToBytes("1234567890123456","ASCII"))
data = bconv.StringToBytes(DataToEncrypt, "ASCII")
data = c.Encrypt(data, kg.Key, True)
Return B64.EncodeBtoS(data, 0, data.Length)
End Sub
In B4J fails in this line:
B4X:
data = c.Encrypt(data, kg.Key, True)
Log says:
B4X:
java.security.InvalidKeyException: Invalid key length: 16 bytes
What's wrong??