My favorites | Sign in
Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#tag Window
Begin Window Window1
BackColor = 16777215
Backdrop = ""
CloseButton = True
Composite = False
Frame = 0
FullScreen = False
HasBackColor = False
Height = 432
ImplicitInstance= True
LiveResize = True
MacProcID = 0
MaxHeight = 32000
MaximizeButton = False
MaxWidth = 32000
MenuBar = 430950399
MenuBarVisible = True
MinHeight = 64
MinimizeButton = True
MinWidth = 64
Placement = 0
Resizeable = True
Title = "Untitled"
Visible = True
Width = 600
Begin PushButton btnGenerate
AutoDeactivate = True
Bold = ""
Cancel = ""
Caption = "Generate"
Default = ""
Enabled = True
Height = 29
HelpTag = ""
Index = -2147483648
InitialParent = ""
Italic = ""
Left = 500
LockBottom = True
LockedInPosition= False
LockLeft = ""
LockRight = True
LockTop = ""
Scope = 0
TabIndex = 0
TabPanelIndex = 0
TabStop = True
TextFont = "System"
TextSize = 0
Top = 390
Underline = ""
Visible = True
Width = 80
End
Begin TextArea taCode
AcceptTabs = ""
Alignment = 0
AutoDeactivate = True
BackColor = 16777215
Bold = ""
Border = True
DataField = ""
DataSource = ""
Enabled = True
Format = ""
Height = 364
HelpTag = ""
HideSelection = True
Index = -2147483648
InitialParent = ""
Italic = ""
Left = 20
LimitText = 0
LockBottom = True
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = True
Mask = ""
Multiline = True
ReadOnly = ""
Scope = 0
ScrollbarHorizontal= ""
ScrollbarVertical= True
Styled = ""
TabIndex = 1
TabPanelIndex = 0
TabStop = True
Text = ""
TextColor = 0
TextFont = "System"
TextSize = 0
Top = 15
Underline = ""
UseFocusRing = True
Visible = True
Width = 560
End
Begin TextField tfPlainText
AcceptTabs = ""
Alignment = 0
AutoDeactivate = True
BackColor = 16777215
Bold = ""
Border = True
CueText = ""
DataField = ""
DataSource = ""
Enabled = True
Format = ""
Height = 22
HelpTag = ""
Index = -2147483648
InitialParent = ""
Italic = ""
Left = 20
LimitText = 0
LockBottom = True
LockedInPosition= False
LockLeft = True
LockRight = True
LockTop = ""
Mask = ""
Password = ""
ReadOnly = ""
Scope = 0
TabIndex = 2
TabPanelIndex = 0
TabStop = True
Text = "Hello World"
TextColor = 0
TextFont = "System"
TextSize = 0
Top = 393
Underline = ""
UseFocusRing = True
Visible = True
Width = 392
End
Begin CheckBox chkAddcaller
AutoDeactivate = True
Bold = ""
Caption = "Caller"
DataField = ""
DataSource = ""
Enabled = True
Height = 20
HelpTag = ""
Index = -2147483648
InitialParent = ""
Italic = ""
Left = 418
LockBottom = True
LockedInPosition= False
LockLeft = ""
LockRight = True
LockTop = ""
Scope = 0
State = 0
TabIndex = 3
TabPanelIndex = 0
TabStop = True
TextFont = "System"
TextSize = 0
Top = 395
Underline = ""
Value = False
Visible = True
Width = 78
End
End
#tag EndWindow

#tag WindowCode
#tag Method, Flags = &h0
Function generator(inText As String, ByRef functionName As String) As String
dim b64 as String = EncodeBase64( inText,0 )
dim b64len As String = Format( b64.Len , "0" )
dim arry() As String = Split( b64, "" )
dim ctr() As Integer
for i As Integer = 0 to UBound( arry )
ctr.Append i
next
ctr.Shuffle

functionName = randomIdentifier
dim mb As String = randomIdentifier( 4, 7 )
dim code() As String
code.Append "Function " + functionName + "() As String"
code.Append " Dim " + mb + " As new MemoryBlock( "+ b64len +" )"
for i as Integer = 0 to UBound( arry )
dim num As Integer = ctr( i )
code.Append " " + mb + ".UInt8Value(" + _
format( num ,"0") + _
")= " + format( asc( arry( num ) ), "0" )
next
code.Append " Return DecodeBase64( " + mb + ".StringValue( 0, " + b64len +" ) )"
code.Append "End Function"

Return join( code, EndOfLine )
End Function
#tag EndMethod

#tag Method, Flags = &h0
Function randomIdentifier(minLength As Integer = 6, maxLength As Integer = 10) As String
dim chars As String = _
"abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"
static r As new Random
dim pos As Integer = r.InRange( 1, 26 )
dim retVal as String = Mid( chars, pos, 1 )
dim maxI As Integer = r.InRange( minLength-1, maxLength-1 )
for i as Integer = 1 to maxI
pos = r.InRange( 1, 62 )
retVal = retVal + Mid( chars, pos, 1 )
next

Return retVal
End Function
#tag EndMethod


#tag EndWindowCode

#tag Events btnGenerate
#tag Event
Sub Action()
dim fName As String
taCode.Text = generator( tfPlainText.Text, fName )
if chkAddcaller.Value Then
taCode.Text = taCode.Text + EndOfLine + EndOfLine + _
"Sub Caller() " +EndOfLine + _
" Dim s as String = " + fName + "()" + EndOfLine + _
"End Sub"
end if
End Sub
#tag EndEvent
#tag EndEvents
#tag Events taCode
#tag Event
Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean
dim m As MenuItem
base.Append EditMenu
m = new MenuItem( "CopyBefore")
if me.SelStart <= 0 then
m.Enabled = False
end if
base.Append m
m = new MenuItem( "CopyAfter")
if me.SelStart >= me.Text.Len then
m.Enabled = False
end if
base.Append m
m = new MenuItem( "CopyAll")
if me.Text.Len <= 0 then
m.Enabled = False
end if
base.Append m
End Function
#tag EndEvent
#tag Event
Function ContextualMenuAction(hitItem as MenuItem) As Boolean
if hitItem.Text = "CopyAll" then
dim clp As new Clipboard
clp.Text = ReplaceLineEndings( me.Text, EndOfLine )
Return True
end if
if hitItem.Text = "CopyBefore" then
dim tmp As Integer = me.SelStart
me.SelStart = 0
me.SelLength = tmp
me.Copy
dim clp As new Clipboard
clp.Text = ReplaceLineEndings( clp.Text, EndOfLine )
Return True
end if
if hitItem.Text = "CopyAfter" then
me.SelLength = me.text.Len
me.Copy
dim clp As new Clipboard
clp.Text = ReplaceLineEndings( clp.Text, EndOfLine )
Return True
end if
End Function
#tag EndEvent
#tag EndEvents
Show details Hide details

Change log

r31 by steve.garman on Sep 29, 2009   Diff
Added obfuscateTest - standalone app to
generate code that hides strings.
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 8318 bytes, 286 lines
Hosted by Google Code