I have a B4J Server that runs an encrypt/decrypt routine while send/receive data
Also, I have a B4i App that do exactly the same and comunicate with the B4j server.
The Encrypt/Decrypt routines for B4J are:
B4X:
Public Sub EncryptText(text As String) As String
Dim c As B4XCipher
Dim su As StringUtils
Return su.EncodeBase64(c.Encrypt(text.GetBytes("utf8"), "Manolito10"))
End Sub
Public Sub DecryptText(EncryptedData As String) As String
Dim c As B4XCipher
Dim su As StringUtils
Dim b() As Byte = c.Decrypt(su.DecodeBase64(EncryptedData), "Manolito10")
Return BytesToString(b, 0, b.Length, "utf8")
End Sub
The Encrypt/Decrypt routines for B4i are:
B4X:
Public Sub EncryptText(text As String) As String
Dim c As Cipher
Dim su As StringUtils
Return su.EncodeBase64(c.Encrypt(text.GetBytes("utf8"), "Manolito10"))
End Sub
Public Sub DecryptText(EncryptedData As String) As String
Dim c As Cipher
Dim su As StringUtils
Dim b() As Byte = c.Decrypt(su.DecodeBase64(EncryptedData), "Manolito10")
Return BytesToString(b, 0, b.Length, "utf8")
End Sub
If I take out the Encrypt/Decrypt routines everything works great but including those routines it does not work
Can anyone help me? please
Many thanks to take the time to read my thread
although there is no harm in adding it the B4J code as well, if you want to maximize your sanity by minimizing your code differences between various platforms ;-)
@emexes : someone needs to post a bug report so a proper fix can be done. As pointed out by @Sandman in the other thread, the given solution may introduce other subtle bugs. We need a real fix, not a workaround
@emexes : someone needs to post a bug report so a proper fix can be done. As pointed out by @Sandman in the other thread, the given solution may introduce other subtle bugs. We need a real fix, not a workaround
Thank you. Tip: use ByteConverter to examine raw bytes:
B4X:
Dim msg As String = "3670BB9F//16RR22200732409191110069"
Log(msg.Length)
Dim c As Cipher
Dim encryptedBytes() As Byte = c.Encrypt(msg.GetBytes("ascii"), "SecurePassword")
Dim dec() As Byte = c.Decrypt(encryptedBytes, "SecurePassword")
Log(dec.Length)
Log(BytesToString(dec, 0, dec.Length, "ascii"))
Dim bc As ByteConverter
Log(bc.HexFromBytes(dec))