Hi,
I am using a component from this company http://www.nsoftware.com/ipworks/encrypt/
Using AES library I encrypt data on a Windows program.
I need to decode the information on B4A android application.
Input text: Basic4Android
Output from Windows app : 22416A4940CCFCF0B2FD7559AA9C8179
Password: password
This is a function I adapted to decode the text:
Sub Decrypt(encryptedData 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 p As String
Dim md As MessageDigest
c.Initialize("AES/CBC/PKCS5Padding")
kg.Initialize("AES")
p = "password"
kg.KeyFromBytes(p.GetBytes("UTF8"))
data = B64.DecodeStoB(encryptedData)
data = c.Decrypt(data, kg.Key, False)
Return Bconv.StringFromBytes(data, "UTF8")
End Sub
This functionis called like that : Decrypt("22416A4940CCFCF0B2FD7559AA9C8179")
I am expecting to have back the text Basic4Android
Here is the error message I am getting:
java.security.InvalidKeyException: no IV set when one expected.
Where am I wrong ?
Thank you for your help.
Marcel.
I am using a component from this company http://www.nsoftware.com/ipworks/encrypt/
Using AES library I encrypt data on a Windows program.
I need to decode the information on B4A android application.
Input text: Basic4Android
Output from Windows app : 22416A4940CCFCF0B2FD7559AA9C8179
Password: password
This is a function I adapted to decode the text:
Sub Decrypt(encryptedData 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 p As String
Dim md As MessageDigest
c.Initialize("AES/CBC/PKCS5Padding")
kg.Initialize("AES")
p = "password"
kg.KeyFromBytes(p.GetBytes("UTF8"))
data = B64.DecodeStoB(encryptedData)
data = c.Decrypt(data, kg.Key, False)
Return Bconv.StringFromBytes(data, "UTF8")
End Sub
This functionis called like that : Decrypt("22416A4940CCFCF0B2FD7559AA9C8179")
I am expecting to have back the text Basic4Android
Here is the error message I am getting:
java.security.InvalidKeyException: no IV set when one expected.
Where am I wrong ?
Thank you for your help.
Marcel.