#Region Project Attributes
#AdditionalJar: bcprov-jdk15on-150
#End Region
Sub Process_Globals
End Sub
Sub AppStart (Args() As String)
ObfuscateString("innocent looking string", "string that you want to obfuscate")
End Sub
Sub ObfuscateString(key As String, str As String)
Dim e As B4XCipher
Dim bc As ByteConverter
Log(bc.HexFromBytes(e.Encrypt(str.GetBytes("UTF8"), key)))
End Sub
Public Sub ds(key As String, raw As String) As String
Dim c As Cipher
Dim bc As ByteConverter
Return bc.StringFromBytes(c.Decrypt(bc.HexToBytes(raw), key), "utf8")
End Sub
You can use this B4J program (non-UI) to encrypt the string:
It requires ByteConverter and jB4XEncryption libraries.B4X:#Region Project Attributes #AdditionalJar: bcprov-jdk15on-150 #End Region Sub Process_Globals End Sub Sub AppStart (Args() As String) ObfuscateString("innocent looking string", "string that you want to obfuscate") End Sub Sub ObfuscateString(key As String, str As String) Dim e As B4XCipher Dim bc As ByteConverter Log(bc.HexFromBytes(e.Encrypt(str.GetBytes("UTF8"), key))) End Sub
It will log the output. Right click on it and copy it to your B4i program. You can decrypt it with:
Libraries: iRandomAccessFile and iEncryption.B4X:Public Sub ds(key As String, raw As String) As String Dim c As Cipher Dim bc As ByteConverter Return bc.StringFromBytes(c.Decrypt(bc.HexToBytes(raw), key), "utf8") End Sub
Public Sub ds(key As String, raw As String) As String
Dim c As Cipher
Dim b() As Byte = c.Decrypt(bc.HexToBytes(raw), key)
Dim s As String = BytesToString(b, 0, b.Length, "utf8")
Dim i As Int = s.IndexOf(Chr(0))
If i > -1 Then s = s.SubString2(0, i)
Return s
End Sub
Thanks for answer , I tried with another snippet found on the forum at : https://www.b4x.com/android/forum/t...or-b4j-b4a-and-b4i-also-in-url.58773/#contentTry it with:
B4X:Public Sub ds(key As String, raw As String) As String Dim c As Cipher Dim b() As Byte = c.Decrypt(bc.HexToBytes(raw), key) Dim s As String = BytesToString(b, 0, b.Length, "utf8") Dim i As Int = s.IndexOf(Chr(0)) If i > -1 Then s = s.SubString2(0, i) Return s End Sub