hi everyone !
i am trying obfuscate base64 replacing letter by letter using this algorithm below :
note : completes the obfuscation in about 5 seconds, being too slow for software that needs to communicate with the socket server ...
What can i do to improve the performance of this algoritm ?
i am trying obfuscate base64 replacing letter by letter using this algorithm below :
note : completes the obfuscation in about 5 seconds, being too slow for software that needs to communicate with the socket server ...
What can i do to improve the performance of this algoritm ?
B4X:
Sub Base64_Obfuscate(stringcyph As String) As String
Dim TempByte() As Byte = stringcyph.GetBytes("UTF8")
Dim TempCyphered As String = cypher.EncodeBase64(TempByte)
Dim TempResult As String
For i = 0 To TempCyphered.Length-1
'Minusculo
If (TempCyphered.SubString2(i,i+1) = "a") Then
TempResult = TempResult & "h"
else if (TempCyphered.SubString2(i,i+1) = "b") Then
TempResult = TempResult & "l"
else if (TempCyphered.SubString2(i,i+1) = "c") Then
TempResult = TempResult & "V"
else if (TempCyphered.SubString2(i,i+1) = "d") Then
TempResult = TempResult & "b"
else if (TempCyphered.SubString2(i,i+1) = "e") Then
TempResult = TempResult & "H"
else if (TempCyphered.SubString2(i,i+1) = "f") Then
TempResult = TempResult & "J"
else if (TempCyphered.SubString2(i,i+1) = "g") Then
TempResult = TempResult & "P"
else if (TempCyphered.SubString2(i,i+1) = "h") Then
TempResult = TempResult & "s"
else if (TempCyphered.SubString2(i,i+1) = "i") Then
TempResult = TempResult & "N"
else if (TempCyphered.SubString2(i,i+1) = "j") Then
TempResult = TempResult & "e"
else if (TempCyphered.SubString2(i,i+1) = "k") Then
TempResult = TempResult & "T"
else if (TempCyphered.SubString2(i,i+1) = "l") Then
TempResult = TempResult & "g"
else if (TempCyphered.SubString2(i,i+1) = "m") Then
TempResult = TempResult & "X"
else if (TempCyphered.SubString2(i,i+1) = "n") Then
TempResult = TempResult & "n"
else if (TempCyphered.SubString2(i,i+1) = "o") Then
TempResult = TempResult & "c"
else if (TempCyphered.SubString2(i,i+1) = "p") Then
TempResult = TempResult & "W"
else if (TempCyphered.SubString2(i,i+1) = "q") Then
TempResult = TempResult & "K"
else if (TempCyphered.SubString2(i,i+1) = "r") Then
TempResult = TempResult & "d"
else if (TempCyphered.SubString2(i,i+1) = "s") Then
TempResult = TempResult & "q"
else if (TempCyphered.SubString2(i,i+1) = "t") Then
TempResult = TempResult & "a"
else if (TempCyphered.SubString2(i,i+1) = "u") Then
TempResult = TempResult & "G"
else if (TempCyphered.SubString2(i,i+1) = "v") Then
TempResult = TempResult & "O"
else if (TempCyphered.SubString2(i,i+1) = "w") Then
TempResult = TempResult & "t"
else if (TempCyphered.SubString2(i,i+1) = "x") Then
TempResult = TempResult & "L"
else if (TempCyphered.SubString2(i,i+1) = "y") Then
TempResult = TempResult & "i"
else if (TempCyphered.SubString2(i,i+1) = "z") Then
TempResult = TempResult & "m"
'Maiusculo
else if (TempCyphered.SubString2(i,i+1) = "A") Then
TempResult = TempResult & "j"
else if (TempCyphered.SubString2(i,i+1) = "B") Then
TempResult = TempResult & "f"
else if (TempCyphered.SubString2(i,i+1) = "C") Then
TempResult = TempResult & "p"
else if (TempCyphered.SubString2(i,i+1) = "D") Then
TempResult = TempResult & "o"
else if (TempCyphered.SubString2(i,i+1) = "E") Then
TempResult = TempResult & "z"
else if (TempCyphered.SubString2(i,i+1) = "F") Then
TempResult = TempResult & "u"
else if (TempCyphered.SubString2(i,i+1) = "G") Then
TempResult = TempResult & "v"
else if (TempCyphered.SubString2(i,i+1) = "H") Then
TempResult = TempResult & "r"
else if (TempCyphered.SubString2(i,i+1) = "I") Then
TempResult = TempResult & "k"
else if (TempCyphered.SubString2(i,i+1) = "J") Then
TempResult = TempResult & "x"
else if (TempCyphered.SubString2(i,i+1) = "K") Then
TempResult = TempResult & "R"
else if (TempCyphered.SubString2(i,i+1) = "L") Then
TempResult = TempResult & "U"
else if (TempCyphered.SubString2(i,i+1) = "M") Then
TempResult = TempResult & "y"
else if (TempCyphered.SubString2(i,i+1) = "N") Then
TempResult = TempResult & "S"
else if (TempCyphered.SubString2(i,i+1) = "O") Then
TempResult = TempResult & "D"
else if (TempCyphered.SubString2(i,i+1) = "P") Then
TempResult = TempResult & "I"
else if (TempCyphered.SubString2(i,i+1) = "Q") Then
TempResult = TempResult & "C"
else if (TempCyphered.SubString2(i,i+1) = "R") Then
TempResult = TempResult & "A"
else if (TempCyphered.SubString2(i,i+1) = "S") Then
TempResult = TempResult & "E"
else if (TempCyphered.SubString2(i,i+1) = "T") Then
TempResult = TempResult & "F"
else if (TempCyphered.SubString2(i,i+1) = "U") Then
TempResult = TempResult & "Z"
else if (TempCyphered.SubString2(i,i+1) = "V") Then
TempResult = TempResult & "Q"
else if (TempCyphered.SubString2(i,i+1) = "W") Then
TempResult = TempResult & "B"
else if (TempCyphered.SubString2(i,i+1) = "X") Then
TempResult = TempResult & "M"
else if (TempCyphered.SubString2(i,i+1) = "Y") Then
TempResult = TempResult & "y"
else if (TempCyphered.SubString2(i,i+1) = "Z") Then
TempResult = TempResult & "w"
Else
TempResult = TempResult & TempCyphered.SubString2(i,i+1)
End If
Next
Return TempResult
End Sub