Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Split long string in codedom?

OK, so I know that when a string is too long, you need to split it in order to compile it.

You use the following format:

Code
Dim Str As String = "asdhkajshdkajsd" & _
                                            "asdasdasdasd"

Now, when a string is placed into the source file, how do people split the long string with that format?

If you don't know what I mean here's an example:

Code
Dim Str As String = "^LongString^"
^LongString^ gets replaced by a very long string by the builder

The string is too long for codedom to compile the application

You would then split the string before compiling the application



Now, how do you split the string before compiling the application?
Look at my recent vb.net section threads and you will find the answer. Please close this thread now.
You can either compress your string or you can use a stringbuilder, ...
You should indeed check out mephobia's thread.
Hang on, I have a string builder in my crypter, i'll update this post with the source.

edit:
Have this somewhere in the builder where you'll be splitting the string and putting it into the stub:

PHP Code

<?php 
'splitting for codedom
    Public Shared Function format(ByVal input As Byte()) As String ' 
Codedom has maximum of possible chars per line so we are storing the string in multiple strings
  Dim out 
As New System.Text.StringBuilder ' Declaring a new StringBuilder to store the output string
  Dim base64data As String = Convert.ToBase64String(input) ' 
Get a readable String from the Byte Array
  
Dim arr As String() = SplitString(base64data, 50000) ' Split the string into parts to fit in the Codedom-lines
  For i As Integer = 0 To arr.Length - 1 ' 
Looping thought each string in the array
    If 
i = arr.Length - 1 Then  ' If i equals the highest number
    out.Append(Chr(34) & arr(i) & Chr(34))
    Else '
I is smaller than arr.Length - 1 (i < arr.Length - 1)
    
out.Append(Chr(34) & arr(i) & Chr(34) & " + " & vbNewLine)
    
End If
  
Next
  
Return out.ToString
    End 
Function

    Private 
Shared Function SplitString(ByVal input As String, ByVal partsize As Long) As String()
  
Dim amount As Long = Math.Ceiling(input.Length / partsize) 'Get Long value of the amount of parts using the formular (Length of Input / Length of Parts)
  Dim out(amount - 1) As String '
Declaring the Array to Return using the amount of Parts to define the size
  Dim currentpos 
As Long = 0 ' Declaring the Currentposition in the String
  For I As Integer = 0 To amount - 1 ' 
Looping thought each string in the array
    If 
I = amount - 1 Then ' If i equals the highest number
    Dim temp((input.Length - currentpos) - 1) As Char ' 
Declaring a temporary Array of Chars for storing the current Part of the String
    input
.CopyTo(currentpos, temp, 0, (input.Length - currentpos)) ' Current part is everything left from the string
    out(I) = Convert.ToString(temp) ' 
Current part is appended to the output string
    
Else 'I is smaller than amount - 1 (i < amount - 1)
    Dim temp(partsize - 1) As Char ' 
Declaring a temporary Array of Chars for storing the current Part if the String using the Size of a part (partsize)
    
input.CopyTo(currentpos, temp, 0, partsize) ' Copying the current Part to the temp array
    out(I) = Convert.ToString(temp) ' 
Current part is appended to the output string
    currentpos 
+= partsize ' Currentposition is increase to catch the next part in the next "round" of the loop
    End If
  Next
  Return out ' 
Return the Output String
    End 
Function

    Private 
Sub addUrl_Click(sender As System.Object, e As System.EventArgs) Handles addUrl.Click
  dlList
.Items.Add(dlUrl.Text)
    
End Sub

    
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  Dim amountofchars 
As Integer = namespacechars.Value()
  
Dim Letters As New List(Of Integer)
  
'lowercase letters
  For i As Integer = 97 To 122
    Letters.Add(i)
  Next
  '
uppercase letters
  
For i As Integer = 65 To 90
    Letters
.Add(i)
  
Next
  
'select 8 random integers from number of items in Letters
  '
then convert those random integers to characters and
  
'add each to a string and display in Textbox
  Dim Rnd As New Random
  Dim SB As New System.Text.StringBuilder
  Dim Temp As Integer
  For count As Integer = 1 To amountofchars
    Temp = Rnd.Next(0, Letters.Count)
    SB.Append(Chr(Letters(Temp)))
  Next
  cNamespace.Text = SB.ToString
  cClass.Text = SB.ToString
    End Sub 

Next you can use it the following way:

PHP Code

<?php 
Dim out 
As New System.Text.StringBuilder ' Declaring a new StringBuilder to store the output string
  Dim arr As String() = SplitString(**YOUR STRING HERE**, 50000) ' 
Split the string into parts to fit in the Codedom-lines
  
For i As Integer = 0 To arr.Length - 1 ' Looping tho btwught each string in the array
    If i = arr.Length - 1 Then  ' 
If i equals the highest number
    out
.Append(Chr(34) & arr(i) & Chr(34))
    Else 
'I is smaller than arr.Length - 1 (i < arr.Length - 1)
    out.Append(Chr(34) & arr(i) & Chr(34) & " + " & vbNewLine)
    End If
  Next 

replace YOUR STRING HERE with your string.
Afterwards your new string will be named "out"

If you look at the code properly you'll realise.

[Image: cWKoYK1.gif]
https://hackforums.net/showthread.php?ti...id25839917
(Aug 27, 2012 04:21 AM)Pumpkins Wrote:  Hang on, I have a string builder in my crypter, i'll update this post with the source.

edit:
Have this somewhere in the builder where you'll be splitting the string and putting it into the stub:

PHP Code

<?php 
'splitting for codedom
    Public Shared Function format(ByVal input As Byte()) As String ' 
Codedom has maximum of possible chars per line so we are storing the string in multiple strings
  Dim out 
As New System.Text.StringBuilder ' Declaring a new StringBuilder to store the output string
  Dim base64data As String = Convert.ToBase64String(input) ' 
Get a readable String from the Byte Array
  
Dim arr As String() = SplitString(base64data, 50000) ' Split the string into parts to fit in the Codedom-lines
  For i As Integer = 0 To arr.Length - 1 ' 
Looping thought each string in the array
    If 
i = arr.Length - 1 Then  ' If i equals the highest number
    out.Append(Chr(34) & arr(i) & Chr(34))
    Else '
I is smaller than arr.Length - 1 (i < arr.Length - 1)
    
out.Append(Chr(34) & arr(i) & Chr(34) & " + " & vbNewLine)
    
End If
  
Next
  
Return out.ToString
    End 
Function

    Private 
Shared Function SplitString(ByVal input As String, ByVal partsize As Long) As String()
  
Dim amount As Long = Math.Ceiling(input.Length / partsize) 'Get Long value of the amount of parts using the formular (Length of Input / Length of Parts)
  Dim out(amount - 1) As String '
Declaring the Array to Return using the amount of Parts to define the size
  Dim currentpos 
As Long = 0 ' Declaring the Currentposition in the String
  For I As Integer = 0 To amount - 1 ' 
Looping thought each string in the array
    If 
I = amount - 1 Then ' If i equals the highest number
    Dim temp((input.Length - currentpos) - 1) As Char ' 
Declaring a temporary Array of Chars for storing the current Part of the String
    input
.CopyTo(currentpos, temp, 0, (input.Length - currentpos)) ' Current part is everything left from the string
    out(I) = Convert.ToString(temp) ' 
Current part is appended to the output string
    
Else 'I is smaller than amount - 1 (i < amount - 1)
    Dim temp(partsize - 1) As Char ' 
Declaring a temporary Array of Chars for storing the current Part if the String using the Size of a part (partsize)
    
input.CopyTo(currentpos, temp, 0, partsize) ' Copying the current Part to the temp array
    out(I) = Convert.ToString(temp) ' 
Current part is appended to the output string
    currentpos 
+= partsize ' Currentposition is increase to catch the next part in the next "round" of the loop
    End If
  Next
  Return out ' 
Return the Output String
    End 
Function

    Private 
Sub addUrl_Click(sender As System.Object, e As System.EventArgs) Handles addUrl.Click
  dlList
.Items.Add(dlUrl.Text)
    
End Sub

    
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  Dim amountofchars 
As Integer = namespacechars.Value()
  
Dim Letters As New List(Of Integer)
  
'lowercase letters
  For i As Integer = 97 To 122
    Letters.Add(i)
  Next
  '
uppercase letters
  
For i As Integer = 65 To 90
    Letters
.Add(i)
  
Next
  
'select 8 random integers from number of items in Letters
  '
then convert those random integers to characters and
  
'add each to a string and display in Textbox
  Dim Rnd As New Random
  Dim SB As New System.Text.StringBuilder
  Dim Temp As Integer
  For count As Integer = 1 To amountofchars
    Temp = Rnd.Next(0, Letters.Count)
    SB.Append(Chr(Letters(Temp)))
  Next
  cNamespace.Text = SB.ToString
  cClass.Text = SB.ToString
    End Sub 

Next you can use it the following way:

PHP Code

<?php 
Dim out 
As New System.Text.StringBuilder ' Declaring a new StringBuilder to store the output string
  Dim arr As String() = SplitString(**YOUR STRING HERE**, 50000) ' 
Split the string into parts to fit in the Codedom-lines
  
For i As Integer = 0 To arr.Length - 1 ' Looping tho btwught each string in the array
    If i = arr.Length - 1 Then  ' 
If i equals the highest number
    out
.Append(Chr(34) & arr(i) & Chr(34))
    Else 
'I is smaller than arr.Length - 1 (i < arr.Length - 1)
    out.Append(Chr(34) & arr(i) & Chr(34) & " + " & vbNewLine)
    End If
  Next 

replace YOUR STRING HERE with your string.
Afterwards your new string will be named "out"

If you look at the code properly you'll realise.

Thank you. This works just fine. Closing thread...


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by MordiciaNov 15, 2019 07:21 PM 3 211 Nov 15, 2019 07:21 PM
Last Post: Mordicia
[Python] by DatageniFeb 4, 2018 04:16 PM 5 143 Feb 4, 2018 04:16 PM
Last Post: TheMarkMan
[C] by FaberCastellSep 10, 2017 07:28 AM 12 443 Sep 10, 2017 07:28 AM
Last Post: Ronnie Coleman