Browse Source

Initial import of util project, with ARC4 encrypter

master
Chris Smith 15 years ago
commit
30386928d7

+ 2
- 0
.gitignore View File

@@ -0,0 +1,2 @@
1
+/build
2
+/nbproject/private

+ 74
- 0
build.xml View File

@@ -0,0 +1,74 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!-- You may freely edit this file. See commented blocks below for -->
3
+<!-- some examples of how to customize the build. -->
4
+<!-- (If you delete it and reopen the project it will be recreated.) -->
5
+<!-- By default, only the Clean and Build commands use this build script. -->
6
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
7
+<!-- the Compile on Save feature is turned off for the project. -->
8
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
9
+<!-- in the project's Project Properties dialog box.-->
10
+<project name="util" default="default" basedir=".">
11
+    <description>Builds, tests, and runs the project util.</description>
12
+    <import file="nbproject/build-impl.xml"/>
13
+    <!--
14
+
15
+    There exist several targets which are by default empty and which can be 
16
+    used for execution of your tasks. These targets are usually executed 
17
+    before and after some main targets. They are: 
18
+
19
+      -pre-init:                 called before initialization of project properties
20
+      -post-init:                called after initialization of project properties
21
+      -pre-compile:              called before javac compilation
22
+      -post-compile:             called after javac compilation
23
+      -pre-compile-single:       called before javac compilation of single file
24
+      -post-compile-single:      called after javac compilation of single file
25
+      -pre-compile-test:         called before javac compilation of JUnit tests
26
+      -post-compile-test:        called after javac compilation of JUnit tests
27
+      -pre-compile-test-single:  called before javac compilation of single JUnit test
28
+      -post-compile-test-single: called after javac compilation of single JUunit test
29
+      -pre-jar:                  called before JAR building
30
+      -post-jar:                 called after JAR building
31
+      -post-clean:               called after cleaning build products
32
+
33
+    (Targets beginning with '-' are not intended to be called on their own.)
34
+
35
+    Example of inserting an obfuscator after compilation could look like this:
36
+
37
+        <target name="-post-compile">
38
+            <obfuscate>
39
+                <fileset dir="${build.classes.dir}"/>
40
+            </obfuscate>
41
+        </target>
42
+
43
+    For list of available properties check the imported 
44
+    nbproject/build-impl.xml file. 
45
+
46
+
47
+    Another way to customize the build is by overriding existing main targets.
48
+    The targets of interest are: 
49
+
50
+      -init-macrodef-javac:     defines macro for javac compilation
51
+      -init-macrodef-junit:     defines macro for junit execution
52
+      -init-macrodef-debug:     defines macro for class debugging
53
+      -init-macrodef-java:      defines macro for class execution
54
+      -do-jar-with-manifest:    JAR building (if you are using a manifest)
55
+      -do-jar-without-manifest: JAR building (if you are not using a manifest)
56
+      run:                      execution of project 
57
+      -javadoc-build:           Javadoc generation
58
+      test-report:              JUnit report generation
59
+
60
+    An example of overriding the target for project execution could look like this:
61
+
62
+        <target name="run" depends="util-impl.jar">
63
+            <exec dir="bin" executable="launcher.exe">
64
+                <arg file="${dist.jar}"/>
65
+            </exec>
66
+        </target>
67
+
68
+    Notice that the overridden target depends on the jar target and not only on 
69
+    the compile target as the regular run target does. Again, for a list of available 
70
+    properties which you can use, check the target you are overriding in the
71
+    nbproject/build-impl.xml file. 
72
+
73
+    -->
74
+</project>

+ 642
- 0
nbproject/build-impl.xml View File

@@ -0,0 +1,642 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!--
3
+*** GENERATED FROM project.xml - DO NOT EDIT  ***
4
+***         EDIT ../build.xml INSTEAD         ***
5
+
6
+For the purpose of easier reading the script
7
+is divided into following sections:
8
+
9
+  - initialization
10
+  - compilation
11
+  - jar
12
+  - execution
13
+  - debugging
14
+  - javadoc
15
+  - junit compilation
16
+  - junit execution
17
+  - junit debugging
18
+  - applet
19
+  - cleanup
20
+
21
+        -->
22
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="util-impl">
23
+    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
24
+    <!-- 
25
+                ======================
26
+                INITIALIZATION SECTION 
27
+                ======================
28
+            -->
29
+    <target name="-pre-init">
30
+        <!-- Empty placeholder for easier customization. -->
31
+        <!-- You can override this target in the ../build.xml file. -->
32
+    </target>
33
+    <target depends="-pre-init" name="-init-private">
34
+        <property file="nbproject/private/config.properties"/>
35
+        <property file="nbproject/private/configs/${config}.properties"/>
36
+        <property file="nbproject/private/private.properties"/>
37
+    </target>
38
+    <target depends="-pre-init,-init-private" name="-init-user">
39
+        <property file="${user.properties.file}"/>
40
+        <!-- The two properties below are usually overridden -->
41
+        <!-- by the active platform. Just a fallback. -->
42
+        <property name="default.javac.source" value="1.4"/>
43
+        <property name="default.javac.target" value="1.4"/>
44
+    </target>
45
+    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
46
+        <property file="nbproject/configs/${config}.properties"/>
47
+        <property file="nbproject/project.properties"/>
48
+    </target>
49
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
50
+        <available file="${manifest.file}" property="manifest.available"/>
51
+        <condition property="manifest.available+main.class">
52
+            <and>
53
+                <isset property="manifest.available"/>
54
+                <isset property="main.class"/>
55
+                <not>
56
+                    <equals arg1="${main.class}" arg2="" trim="true"/>
57
+                </not>
58
+            </and>
59
+        </condition>
60
+        <condition property="manifest.available+main.class+mkdist.available">
61
+            <and>
62
+                <istrue value="${manifest.available+main.class}"/>
63
+                <isset property="libs.CopyLibs.classpath"/>
64
+            </and>
65
+        </condition>
66
+        <condition property="have.tests">
67
+            <or>
68
+                <available file="${test.src.dir}"/>
69
+            </or>
70
+        </condition>
71
+        <condition property="have.sources">
72
+            <or>
73
+                <available file="${src.dir}"/>
74
+            </or>
75
+        </condition>
76
+        <condition property="netbeans.home+have.tests">
77
+            <and>
78
+                <isset property="netbeans.home"/>
79
+                <isset property="have.tests"/>
80
+            </and>
81
+        </condition>
82
+        <condition property="no.javadoc.preview">
83
+            <and>
84
+                <isset property="javadoc.preview"/>
85
+                <isfalse value="${javadoc.preview}"/>
86
+            </and>
87
+        </condition>
88
+        <property name="run.jvmargs" value=""/>
89
+        <property name="javac.compilerargs" value=""/>
90
+        <property name="work.dir" value="${basedir}"/>
91
+        <condition property="no.deps">
92
+            <and>
93
+                <istrue value="${no.dependencies}"/>
94
+            </and>
95
+        </condition>
96
+        <property name="javac.debug" value="true"/>
97
+        <property name="javadoc.preview" value="true"/>
98
+        <property name="application.args" value=""/>
99
+        <property name="source.encoding" value="${file.encoding}"/>
100
+        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
101
+            <and>
102
+                <isset property="javadoc.encoding"/>
103
+                <not>
104
+                    <equals arg1="${javadoc.encoding}" arg2=""/>
105
+                </not>
106
+            </and>
107
+        </condition>
108
+        <property name="javadoc.encoding.used" value="${source.encoding}"/>
109
+        <property name="includes" value="**"/>
110
+        <property name="excludes" value=""/>
111
+        <property name="do.depend" value="false"/>
112
+        <condition property="do.depend.true">
113
+            <istrue value="${do.depend}"/>
114
+        </condition>
115
+        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
116
+            <and>
117
+                <isset property="jaxws.endorsed.dir"/>
118
+                <available file="nbproject/jaxws-build.xml"/>
119
+            </and>
120
+        </condition>
121
+    </target>
122
+    <target name="-post-init">
123
+        <!-- Empty placeholder for easier customization. -->
124
+        <!-- You can override this target in the ../build.xml file. -->
125
+    </target>
126
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
127
+        <fail unless="src.dir">Must set src.dir</fail>
128
+        <fail unless="test.src.dir">Must set test.src.dir</fail>
129
+        <fail unless="build.dir">Must set build.dir</fail>
130
+        <fail unless="dist.dir">Must set dist.dir</fail>
131
+        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
132
+        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
133
+        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
134
+        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
135
+        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
136
+        <fail unless="dist.jar">Must set dist.jar</fail>
137
+    </target>
138
+    <target name="-init-macrodef-property">
139
+        <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
140
+            <attribute name="name"/>
141
+            <attribute name="value"/>
142
+            <sequential>
143
+                <property name="@{name}" value="${@{value}}"/>
144
+            </sequential>
145
+        </macrodef>
146
+    </target>
147
+    <target name="-init-macrodef-javac">
148
+        <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
149
+            <attribute default="${src.dir}" name="srcdir"/>
150
+            <attribute default="${build.classes.dir}" name="destdir"/>
151
+            <attribute default="${javac.classpath}" name="classpath"/>
152
+            <attribute default="${includes}" name="includes"/>
153
+            <attribute default="${excludes}" name="excludes"/>
154
+            <attribute default="${javac.debug}" name="debug"/>
155
+            <attribute default="/does/not/exist" name="sourcepath"/>
156
+            <element name="customize" optional="true"/>
157
+            <sequential>
158
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
159
+                    <classpath>
160
+                        <path path="@{classpath}"/>
161
+                    </classpath>
162
+                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
163
+                    <customize/>
164
+                </javac>
165
+            </sequential>
166
+        </macrodef>
167
+        <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
168
+            <attribute default="${src.dir}" name="srcdir"/>
169
+            <attribute default="${build.classes.dir}" name="destdir"/>
170
+            <attribute default="${javac.classpath}" name="classpath"/>
171
+            <sequential>
172
+                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
173
+                    <classpath>
174
+                        <path path="@{classpath}"/>
175
+                    </classpath>
176
+                </depend>
177
+            </sequential>
178
+        </macrodef>
179
+        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/j2se-project/3">
180
+            <attribute default="${build.classes.dir}" name="destdir"/>
181
+            <sequential>
182
+                <fail unless="javac.includes">Must set javac.includes</fail>
183
+                <pathconvert pathsep="," property="javac.includes.binary">
184
+                    <path>
185
+                        <filelist dir="@{destdir}" files="${javac.includes}"/>
186
+                    </path>
187
+                    <globmapper from="*.java" to="*.class"/>
188
+                </pathconvert>
189
+                <delete>
190
+                    <files includes="${javac.includes.binary}"/>
191
+                </delete>
192
+            </sequential>
193
+        </macrodef>
194
+    </target>
195
+    <target name="-init-macrodef-junit">
196
+        <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
197
+            <attribute default="${includes}" name="includes"/>
198
+            <attribute default="${excludes}" name="excludes"/>
199
+            <attribute default="**" name="testincludes"/>
200
+            <sequential>
201
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
202
+                    <batchtest todir="${build.test.results.dir}">
203
+                        <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
204
+                            <filename name="@{testincludes}"/>
205
+                        </fileset>
206
+                    </batchtest>
207
+                    <classpath>
208
+                        <path path="${run.test.classpath}"/>
209
+                    </classpath>
210
+                    <syspropertyset>
211
+                        <propertyref prefix="test-sys-prop."/>
212
+                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
213
+                    </syspropertyset>
214
+                    <formatter type="brief" usefile="false"/>
215
+                    <formatter type="xml"/>
216
+                    <jvmarg line="${run.jvmargs}"/>
217
+                </junit>
218
+            </sequential>
219
+        </macrodef>
220
+    </target>
221
+    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
222
+        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
223
+            <attribute default="${main.class}" name="name"/>
224
+            <attribute default="${debug.classpath}" name="classpath"/>
225
+            <attribute default="" name="stopclassname"/>
226
+            <sequential>
227
+                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
228
+                    <classpath>
229
+                        <path path="@{classpath}"/>
230
+                    </classpath>
231
+                </nbjpdastart>
232
+            </sequential>
233
+        </macrodef>
234
+        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
235
+            <attribute default="${build.classes.dir}" name="dir"/>
236
+            <sequential>
237
+                <nbjpdareload>
238
+                    <fileset dir="@{dir}" includes="${fix.classes}">
239
+                        <include name="${fix.includes}*.class"/>
240
+                    </fileset>
241
+                </nbjpdareload>
242
+            </sequential>
243
+        </macrodef>
244
+    </target>
245
+    <target name="-init-debug-args">
246
+        <property name="version-output" value="java version &quot;${ant.java.version}"/>
247
+        <condition property="have-jdk-older-than-1.4">
248
+            <or>
249
+                <contains string="${version-output}" substring="java version &quot;1.0"/>
250
+                <contains string="${version-output}" substring="java version &quot;1.1"/>
251
+                <contains string="${version-output}" substring="java version &quot;1.2"/>
252
+                <contains string="${version-output}" substring="java version &quot;1.3"/>
253
+            </or>
254
+        </condition>
255
+        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
256
+            <istrue value="${have-jdk-older-than-1.4}"/>
257
+        </condition>
258
+        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
259
+            <os family="windows"/>
260
+        </condition>
261
+        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
262
+            <isset property="debug.transport"/>
263
+        </condition>
264
+    </target>
265
+    <target depends="-init-debug-args" name="-init-macrodef-debug">
266
+        <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
267
+            <attribute default="${main.class}" name="classname"/>
268
+            <attribute default="${debug.classpath}" name="classpath"/>
269
+            <element name="customize" optional="true"/>
270
+            <sequential>
271
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
272
+                    <jvmarg line="${debug-args-line}"/>
273
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
274
+                    <jvmarg line="${run.jvmargs}"/>
275
+                    <classpath>
276
+                        <path path="@{classpath}"/>
277
+                    </classpath>
278
+                    <syspropertyset>
279
+                        <propertyref prefix="run-sys-prop."/>
280
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
281
+                    </syspropertyset>
282
+                    <customize/>
283
+                </java>
284
+            </sequential>
285
+        </macrodef>
286
+    </target>
287
+    <target name="-init-macrodef-java">
288
+        <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
289
+            <attribute default="${main.class}" name="classname"/>
290
+            <element name="customize" optional="true"/>
291
+            <sequential>
292
+                <java classname="@{classname}" dir="${work.dir}" fork="true">
293
+                    <jvmarg line="${run.jvmargs}"/>
294
+                    <classpath>
295
+                        <path path="${run.classpath}"/>
296
+                    </classpath>
297
+                    <syspropertyset>
298
+                        <propertyref prefix="run-sys-prop."/>
299
+                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
300
+                    </syspropertyset>
301
+                    <customize/>
302
+                </java>
303
+            </sequential>
304
+        </macrodef>
305
+    </target>
306
+    <target name="-init-presetdef-jar">
307
+        <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
308
+            <jar compress="${jar.compress}" jarfile="${dist.jar}">
309
+                <j2seproject1:fileset dir="${build.classes.dir}"/>
310
+            </jar>
311
+        </presetdef>
312
+    </target>
313
+    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
314
+    <!--
315
+                ===================
316
+                COMPILATION SECTION
317
+                ===================
318
+            -->
319
+    <target depends="init" name="deps-jar" unless="no.deps"/>
320
+    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
321
+    <target depends="init" name="-check-automatic-build">
322
+        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
323
+    </target>
324
+    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
325
+        <antcall target="clean"/>
326
+    </target>
327
+    <target depends="init,deps-jar" name="-pre-pre-compile">
328
+        <mkdir dir="${build.classes.dir}"/>
329
+    </target>
330
+    <target name="-pre-compile">
331
+        <!-- Empty placeholder for easier customization. -->
332
+        <!-- You can override this target in the ../build.xml file. -->
333
+    </target>
334
+    <target if="do.depend.true" name="-compile-depend">
335
+        <j2seproject3:depend/>
336
+    </target>
337
+    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
338
+        <j2seproject3:javac/>
339
+        <copy todir="${build.classes.dir}">
340
+            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
341
+        </copy>
342
+    </target>
343
+    <target name="-post-compile">
344
+        <!-- Empty placeholder for easier customization. -->
345
+        <!-- You can override this target in the ../build.xml file. -->
346
+    </target>
347
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
348
+    <target name="-pre-compile-single">
349
+        <!-- Empty placeholder for easier customization. -->
350
+        <!-- You can override this target in the ../build.xml file. -->
351
+    </target>
352
+    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
353
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
354
+        <j2seproject3:force-recompile/>
355
+        <j2seproject3:javac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
356
+    </target>
357
+    <target name="-post-compile-single">
358
+        <!-- Empty placeholder for easier customization. -->
359
+        <!-- You can override this target in the ../build.xml file. -->
360
+    </target>
361
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
362
+    <!--
363
+                ====================
364
+                JAR BUILDING SECTION
365
+                ====================
366
+            -->
367
+    <target depends="init" name="-pre-pre-jar">
368
+        <dirname file="${dist.jar}" property="dist.jar.dir"/>
369
+        <mkdir dir="${dist.jar.dir}"/>
370
+    </target>
371
+    <target name="-pre-jar">
372
+        <!-- Empty placeholder for easier customization. -->
373
+        <!-- You can override this target in the ../build.xml file. -->
374
+    </target>
375
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
376
+        <j2seproject1:jar/>
377
+    </target>
378
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
379
+        <j2seproject1:jar manifest="${manifest.file}"/>
380
+    </target>
381
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
382
+        <j2seproject1:jar manifest="${manifest.file}">
383
+            <j2seproject1:manifest>
384
+                <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
385
+            </j2seproject1:manifest>
386
+        </j2seproject1:jar>
387
+        <echo>To run this application from the command line without Ant, try:</echo>
388
+        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
389
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
390
+        <pathconvert property="run.classpath.with.dist.jar">
391
+            <path path="${run.classpath}"/>
392
+            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
393
+        </pathconvert>
394
+        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
395
+    </target>
396
+    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
397
+        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
398
+        <pathconvert property="run.classpath.without.build.classes.dir">
399
+            <path path="${run.classpath}"/>
400
+            <map from="${build.classes.dir.resolved}" to=""/>
401
+        </pathconvert>
402
+        <pathconvert pathsep=" " property="jar.classpath">
403
+            <path path="${run.classpath.without.build.classes.dir}"/>
404
+            <chainedmapper>
405
+                <flattenmapper/>
406
+                <globmapper from="*" to="lib/*"/>
407
+            </chainedmapper>
408
+        </pathconvert>
409
+        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
410
+        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
411
+            <fileset dir="${build.classes.dir}"/>
412
+            <manifest>
413
+                <attribute name="Main-Class" value="${main.class}"/>
414
+                <attribute name="Class-Path" value="${jar.classpath}"/>
415
+            </manifest>
416
+        </copylibs>
417
+        <echo>To run this application from the command line without Ant, try:</echo>
418
+        <property location="${dist.jar}" name="dist.jar.resolved"/>
419
+        <echo>java -jar "${dist.jar.resolved}"</echo>
420
+    </target>
421
+    <target name="-post-jar">
422
+        <!-- Empty placeholder for easier customization. -->
423
+        <!-- You can override this target in the ../build.xml file. -->
424
+    </target>
425
+    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
426
+    <!--
427
+                =================
428
+                EXECUTION SECTION
429
+                =================
430
+            -->
431
+    <target depends="init,compile" description="Run a main class." name="run">
432
+        <j2seproject1:java>
433
+            <customize>
434
+                <arg line="${application.args}"/>
435
+            </customize>
436
+        </j2seproject1:java>
437
+    </target>
438
+    <target name="-do-not-recompile">
439
+        <property name="javac.includes.binary" value=""/>
440
+    </target>
441
+    <target depends="init,-do-not-recompile,compile-single" name="run-single">
442
+        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
443
+        <j2seproject1:java classname="${run.class}"/>
444
+    </target>
445
+    <!--
446
+                =================
447
+                DEBUGGING SECTION
448
+                =================
449
+            -->
450
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
451
+        <j2seproject1:nbjpdastart name="${debug.class}"/>
452
+    </target>
453
+    <target depends="init,compile" name="-debug-start-debuggee">
454
+        <j2seproject3:debug>
455
+            <customize>
456
+                <arg line="${application.args}"/>
457
+            </customize>
458
+        </j2seproject3:debug>
459
+    </target>
460
+    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
461
+    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
462
+        <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
463
+    </target>
464
+    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
465
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
466
+        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
467
+        <j2seproject3:debug classname="${debug.class}"/>
468
+    </target>
469
+    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
470
+    <target depends="init" name="-pre-debug-fix">
471
+        <fail unless="fix.includes">Must set fix.includes</fail>
472
+        <property name="javac.includes" value="${fix.includes}.java"/>
473
+    </target>
474
+    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
475
+        <j2seproject1:nbjpdareload/>
476
+    </target>
477
+    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
478
+    <!--
479
+                ===============
480
+                JAVADOC SECTION
481
+                ===============
482
+            -->
483
+    <target depends="init" name="-javadoc-build">
484
+        <mkdir dir="${dist.javadoc.dir}"/>
485
+        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">
486
+            <classpath>
487
+                <path path="${javac.classpath}"/>
488
+            </classpath>
489
+            <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
490
+                <filename name="**/*.java"/>
491
+            </fileset>
492
+        </javadoc>
493
+    </target>
494
+    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
495
+        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
496
+    </target>
497
+    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
498
+    <!--
499
+                =========================
500
+                JUNIT COMPILATION SECTION
501
+                =========================
502
+            -->
503
+    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
504
+        <mkdir dir="${build.test.classes.dir}"/>
505
+    </target>
506
+    <target name="-pre-compile-test">
507
+        <!-- Empty placeholder for easier customization. -->
508
+        <!-- You can override this target in the ../build.xml file. -->
509
+    </target>
510
+    <target if="do.depend.true" name="-compile-test-depend">
511
+        <j2seproject3:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
512
+    </target>
513
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
514
+        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
515
+        <copy todir="${build.test.classes.dir}">
516
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
517
+        </copy>
518
+    </target>
519
+    <target name="-post-compile-test">
520
+        <!-- Empty placeholder for easier customization. -->
521
+        <!-- You can override this target in the ../build.xml file. -->
522
+    </target>
523
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
524
+    <target name="-pre-compile-test-single">
525
+        <!-- Empty placeholder for easier customization. -->
526
+        <!-- You can override this target in the ../build.xml file. -->
527
+    </target>
528
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
529
+        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
530
+        <j2seproject3:force-recompile destdir="${build.test.classes.dir}"/>
531
+        <j2seproject3:javac classpath="${javac.test.classpath}" debug="true" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
532
+        <copy todir="${build.test.classes.dir}">
533
+            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
534
+        </copy>
535
+    </target>
536
+    <target name="-post-compile-test-single">
537
+        <!-- Empty placeholder for easier customization. -->
538
+        <!-- You can override this target in the ../build.xml file. -->
539
+    </target>
540
+    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
541
+    <!--
542
+                =======================
543
+                JUNIT EXECUTION SECTION
544
+                =======================
545
+            -->
546
+    <target depends="init" if="have.tests" name="-pre-test-run">
547
+        <mkdir dir="${build.test.results.dir}"/>
548
+    </target>
549
+    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
550
+        <j2seproject3:junit testincludes="**/*Test.java"/>
551
+    </target>
552
+    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
553
+        <fail if="tests.failed">Some tests failed; see details above.</fail>
554
+    </target>
555
+    <target depends="init" if="have.tests" name="test-report"/>
556
+    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
557
+    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
558
+    <target depends="init" if="have.tests" name="-pre-test-run-single">
559
+        <mkdir dir="${build.test.results.dir}"/>
560
+    </target>
561
+    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
562
+        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
563
+        <j2seproject3:junit excludes="" includes="${test.includes}"/>
564
+    </target>
565
+    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
566
+        <fail if="tests.failed">Some tests failed; see details above.</fail>
567
+    </target>
568
+    <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
569
+    <!--
570
+                =======================
571
+                JUNIT DEBUGGING SECTION
572
+                =======================
573
+            -->
574
+    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
575
+        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
576
+        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
577
+        <delete file="${test.report.file}"/>
578
+        <mkdir dir="${build.test.results.dir}"/>
579
+        <j2seproject3:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
580
+            <customize>
581
+                <syspropertyset>
582
+                    <propertyref prefix="test-sys-prop."/>
583
+                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
584
+                </syspropertyset>
585
+                <arg value="${test.class}"/>
586
+                <arg value="showoutput=true"/>
587
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
588
+                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
589
+            </customize>
590
+        </j2seproject3:debug>
591
+    </target>
592
+    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
593
+        <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
594
+    </target>
595
+    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
596
+    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
597
+        <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
598
+    </target>
599
+    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
600
+    <!--
601
+                =========================
602
+                APPLET EXECUTION SECTION
603
+                =========================
604
+            -->
605
+    <target depends="init,compile-single" name="run-applet">
606
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
607
+        <j2seproject1:java classname="sun.applet.AppletViewer">
608
+            <customize>
609
+                <arg value="${applet.url}"/>
610
+            </customize>
611
+        </j2seproject1:java>
612
+    </target>
613
+    <!--
614
+                =========================
615
+                APPLET DEBUGGING  SECTION
616
+                =========================
617
+            -->
618
+    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
619
+        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
620
+        <j2seproject3:debug classname="sun.applet.AppletViewer">
621
+            <customize>
622
+                <arg value="${applet.url}"/>
623
+            </customize>
624
+        </j2seproject3:debug>
625
+    </target>
626
+    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
627
+    <!--
628
+                ===============
629
+                CLEANUP SECTION
630
+                ===============
631
+            -->
632
+    <target depends="init" name="deps-clean" unless="no.deps"/>
633
+    <target depends="init" name="-do-clean">
634
+        <delete dir="${build.dir}"/>
635
+        <delete dir="${dist.dir}"/>
636
+    </target>
637
+    <target name="-post-clean">
638
+        <!-- Empty placeholder for easier customization. -->
639
+        <!-- You can override this target in the ../build.xml file. -->
640
+    </target>
641
+    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
642
+</project>

+ 8
- 0
nbproject/genfiles.properties View File

@@ -0,0 +1,8 @@
1
+build.xml.data.CRC32=5ecd7009
2
+build.xml.script.CRC32=8451f424
3
+build.xml.stylesheet.CRC32=958a1d3e
4
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6
+nbproject/build-impl.xml.data.CRC32=5ecd7009
7
+nbproject/build-impl.xml.script.CRC32=077c9c82
8
+nbproject/build-impl.xml.stylesheet.CRC32=65b8de21

+ 58
- 0
nbproject/project.properties View File

@@ -0,0 +1,58 @@
1
+build.classes.dir=${build.dir}/classes
2
+build.classes.excludes=**/*.java,**/*.form
3
+# This directory is removed when the project is cleaned:
4
+build.dir=build
5
+build.generated.dir=${build.dir}/generated
6
+# Only compile against the classpath explicitly listed here:
7
+build.sysclasspath=ignore
8
+build.test.classes.dir=${build.dir}/test/classes
9
+build.test.results.dir=${build.dir}/test/results
10
+# Uncomment to specify the preferred debugger connection transport:
11
+#debug.transport=dt_socket
12
+debug.classpath=\
13
+    ${run.classpath}
14
+debug.test.classpath=\
15
+    ${run.test.classpath}
16
+# This directory is removed when the project is cleaned:
17
+dist.dir=dist
18
+dist.jar=${dist.dir}/util.jar
19
+dist.javadoc.dir=${dist.dir}/javadoc
20
+excludes=
21
+includes=**
22
+jar.compress=false
23
+javac.classpath=
24
+# Space-separated list of extra javac options
25
+javac.compilerargs=
26
+javac.deprecation=false
27
+javac.source=1.5
28
+javac.target=1.5
29
+javac.test.classpath=\
30
+    ${javac.classpath}:\
31
+    ${build.classes.dir}:\
32
+    ${libs.junit_4.classpath}
33
+javadoc.additionalparam=
34
+javadoc.author=false
35
+javadoc.encoding=${source.encoding}
36
+javadoc.noindex=false
37
+javadoc.nonavbar=false
38
+javadoc.notree=false
39
+javadoc.private=false
40
+javadoc.splitindex=true
41
+javadoc.use=true
42
+javadoc.version=false
43
+javadoc.windowtitle=
44
+meta.inf.dir=${src.dir}/META-INF
45
+platform.active=default_platform
46
+run.classpath=\
47
+    ${javac.classpath}:\
48
+    ${build.classes.dir}
49
+# Space-separated list of JVM arguments used when running the project
50
+# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
51
+# or test-sys-prop.name=value to set system properties for unit tests):
52
+run.jvmargs=
53
+run.test.classpath=\
54
+    ${javac.test.classpath}:\
55
+    ${build.test.classes.dir}
56
+source.encoding=UTF-8
57
+src.dir=src
58
+test.src.dir=test

+ 16
- 0
nbproject/project.xml View File

@@ -0,0 +1,16 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://www.netbeans.org/ns/project/1">
3
+    <type>org.netbeans.modules.java.j2seproject</type>
4
+    <configuration>
5
+        <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
6
+            <name>util</name>
7
+            <minimum-ant-version>1.6.5</minimum-ant-version>
8
+            <source-roots>
9
+                <root id="src.dir"/>
10
+            </source-roots>
11
+            <test-roots>
12
+                <root id="test.src.dir"/>
13
+            </test-roots>
14
+        </data>
15
+    </configuration>
16
+</project>

+ 96
- 0
src/com/md87/util/crypto/ArcFourEncrypter.java View File

@@ -0,0 +1,96 @@
1
+/*
2
+ * Copyright (c) 2009 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.md87.util.crypto;
24
+
25
+import java.util.Arrays;
26
+
27
+/**
28
+ * Implements the ARC4 algorithm.
29
+ *
30
+ * @author chris
31
+ */
32
+public class ArcFourEncrypter {
33
+
34
+    /** The key to use for encryption. */
35
+    final String key;
36
+
37
+    /** The output of the key scheduling algorithm. */
38
+    final byte[] ostate = new byte[256];
39
+
40
+    /**
41
+     * Creates a new encrypter that will use the specified key.
42
+     *
43
+     * @param key The key to use for encrypting
44
+     */
45
+    public ArcFourEncrypter(final String key) {
46
+        this.key = key;
47
+
48
+        byte[] bytes = key.getBytes();
49
+
50
+        for (int i = 0; i < 256; i++) {
51
+            ostate[i] = (byte) i;
52
+        }
53
+
54
+        int keyindex = 0;
55
+        int stateindex = 0;
56
+
57
+        for (int i = 0; i < 256; i++) {
58
+            final byte t = ostate[i];
59
+            stateindex = (stateindex + bytes[keyindex] + t) & 0xff;
60
+            final byte u = ostate[stateindex];
61
+            ostate[stateindex] = (byte) (t & 0xff);
62
+            ostate[i] = (byte) (u & 0xff);
63
+
64
+            keyindex = (keyindex + 1) % bytes.length;
65
+        }
66
+    }
67
+
68
+    /**
69
+     * Encrypts the specified bytes.
70
+     *
71
+     * @param bytes The bytes to be encrypted
72
+     * @return The encrypted bytes
73
+     */
74
+    public byte[] encrypt(final byte[] bytes) {
75
+        final byte[] state = Arrays.copyOf(ostate, ostate.length);
76
+        final byte[] dest = new byte[bytes.length];
77
+        int x = 0, y = 0;
78
+        
79
+        for (int i = 0; i < bytes.length; i++) {
80
+            byte sx, sy;
81
+
82
+            x = (x + 1) & 0xff;
83
+            sx = state[x];
84
+            y = (sx + y) & 0xff;
85
+            sy = state[y];
86
+
87
+            state[y] = (byte) (sx & 0xff);
88
+            state[x] = (byte) (sy & 0xff);
89
+
90
+            dest[i] = (byte) (((int) bytes[i] ^ state[(sx + sy) & 0xff]) & 0xff);
91
+        }
92
+
93
+        return dest;
94
+    }
95
+    
96
+}

+ 45
- 0
test/com/md87/util/crypto/ArcFourEncrypterTest.java View File

@@ -0,0 +1,45 @@
1
+/*
2
+ * Copyright (c) 2009 Chris Smith
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.md87.util.crypto;
24
+
25
+import org.junit.Test;
26
+import static org.junit.Assert.*;
27
+
28
+public class ArcFourEncrypterTest {
29
+
30
+    @Test
31
+    public void testPredefined() {
32
+        assertArrayEquals(new byte[]{(byte) 0x45, (byte) 0xA0, (byte) 0x1F,
33
+                (byte) 0x64, (byte) 0x5F, (byte) 0xC3, (byte) 0x5B,
34
+                (byte) 0x38, (byte) 0x35, (byte) 0x52, (byte) 0x54,
35
+                (byte) 0x4B, (byte) 0x9B, (byte) 0xF5},
36
+                new ArcFourEncrypter("Secret").encrypt("Attack at dawn".getBytes()));
37
+    }
38
+
39
+    @Test
40
+    public void testDouble() {
41
+        final ArcFourEncrypter enc = new ArcFourEncrypter("Secret");
42
+        assertEquals("Testing", new String(enc.encrypt(enc.encrypt("Testing".getBytes()))));
43
+    }
44
+
45
+}

Loading…
Cancel
Save