iOS Question ios obfuscated

Discussion in 'iOS Questions' started by tufanv, Mar 3, 2015.

  1. tufanv

    tufanv Expert Licensed User

    Hello

    I know that obfuscation is not possilbe during compile with b4i is there any way to crypt,obfuscate etc some strings as in b4a ?

    ty
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You can use this B4J program (non-UI) to encrypt the string:
    Code:
    #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 requires ByteConverter and jB4XEncryption libraries.

    It will log the output. Right click on it and copy it to your B4i program. You can decrypt it with:
    Code:
    Public Sub ds(key As String, raw As StringAs String
       
    Dim c As Cipher
       
    Dim bc As ByteConverter
       
    Return bc.StringFromBytes(c.Decrypt(bc.HexToBytes(raw), key), "utf8")
    End Sub
    Libraries: iRandomAccessFile and iEncryption.
     
    ilan and tufanv like this.
  3. tufanv

    tufanv Expert Licensed User

    this encrypts my url with some squares at the end

    when I paste my encrypted string with key into b4i , I get in the logs some squares at the end of the url and it gives unspported url error at httpjob.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Try it with:
    Code:
    Public Sub ds(key As String, raw As StringAs 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
     
    ilan likes this.
  5. tufanv

    tufanv Expert Licensed User

    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/#content

    It works for me , is this as safe as this one ?
     
    ajk likes this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    Yes. They are based on the same feature.
     
    tufanv likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice