Hi friends,
I`m decrypting with this code :
It is working very good, but I need to decrypt the messages received by firebase, when putting this function in FirebaseMessaging Receiver Module then its failed to decrypt :
This is happening only if the app were closed (not foreground and not background)
if the app is foreground or background then it decrypt fine
and if the app is closed and i am not decrypting then the notification works fine
note : firebase is running fine and as per Erel`s 2023 instructions
Any ideas?
I`m decrypting with this code :
B4X:
Public Sub AES_DecryptB4A(data As String, secretkey As String) As String
Dim SU As StringUtils
Dim kg As KeyGenerator
Dim C As Cipher
Dim md As MessageDigest
Dim Decrypted() As Byte
kg.Initialize("AES")
kg.KeyFromBytes(md.GetMessageDigest(secretkey.GetBytes("UTF8"), "MD5"))
C.Initialize("AES/ECB/PKCS5Padding")
Dim Bytes() As Byte = SU.DecodeBase64(data)
Decrypted = C.Decrypt(Bytes, kg.Key, False)
Return BytesToString(Decrypted, 0, Decrypted.Length, "UTF8")
End Sub
B4X:
(BadPaddingException) javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
if the app is foreground or background then it decrypt fine
and if the app is closed and i am not decrypting then the notification works fine
note : firebase is running fine and as per Erel`s 2023 instructions
Any ideas?