Skip to content

Commit

Permalink
Changed the names of the output files.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruiaraujo committed Sep 6, 2014
1 parent 92fb807 commit 9cde2e4
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bin/
RouterKeygen.*
webdic.dic
/RKDictionary.cfv
/RouterKeygen_v3.dic
12 changes: 12 additions & 0 deletions src/org/exobel/routerkeygen/thomsonGenerator/OutputFilesNames.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.exobel.routerkeygen.thomsonGenerator;

public final class OutputFilesNames {
private OutputFilesNames() {
}

public static final String DIC_NAME = "RouterKeygen_v3.dic";
public static final String WEBDIC_NAME = "webdic.dic";
public static final String CFV_NAME = "RKDictionary.cfv";


}
2 changes: 1 addition & 1 deletion src/org/exobel/routerkeygen/thomsonGenerator/Stage3.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static void main(String[] args) {
byte [] webDicTable = new byte[768];
RandomAccessFile webDicIndex = null;
try {
File webDic = new File("webdic.dic");
File webDic = new File(OutputFilesNames.WEBDIC_NAME);
webDic.delete();
webDic.createNewFile();
webDicIndex = new RandomAccessFile(webDic, "rw");
Expand Down
18 changes: 12 additions & 6 deletions src/org/exobel/routerkeygen/thomsonGenerator/Stage4.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public class Stage4 {

/*
* Version 1 - Initial dictionary of 55.8 MB ( downloaded 740 times )
* Version 2 - Second version with 41.9 MB Version 3 - Third version with
* 28.0 MB
* Version 2 - Second version with 41.9 MB Version 3 - Third version with 28.0 MB
*/
public static final byte[] version = { 0, 4 };

Expand All @@ -31,7 +30,7 @@ public static void main(String[] args) {
byte[] table = new byte[1280];
RandomAccessFile webDicIndex = null;
try {
File webDic = new File("webdic.dic");
File webDic = new File(OutputFilesNames.WEBDIC_NAME);
webDic.createNewFile();
webDicIndex = new RandomAccessFile(webDic, "rw");
webDicIndex.setLength(1024 + 256 * 768);
Expand Down Expand Up @@ -76,9 +75,9 @@ public static void main(String[] args) {
address += count;
}
}
FileOutputStream fos;
FileOutputStream fos = null;
try {
fos = new FileOutputStream("RouterKeygen.dic");
fos = new FileOutputStream(OutputFilesNames.DIC_NAME);
fos.write(version);
entry.toFile(table);
fos.write(table);
Expand Down Expand Up @@ -112,10 +111,17 @@ public static void main(String[] args) {
}
}
}
fos.close();
} catch (IOException e) {
System.out.println("Error!" + e);
return;
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
long time = System.currentTimeMillis() - begin;
System.out.println("Done .. 100%! It took " + time + " miliseconds.");
Expand Down
4 changes: 2 additions & 2 deletions src/org/exobel/routerkeygen/thomsonGenerator/Stage5.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public static void main(String[] args) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");

InputStream is = new FileInputStream("RouterKeygen.dic");
InputStream is = new FileInputStream(OutputFilesNames.DIC_NAME);
is = new DigestInputStream(is, md);
byte [] buffer = new byte [16384] ;
while ( is.read ( buffer ) != -1 );

byte[] digest = md.digest();
is.close();

FileOutputStream fos = new FileOutputStream("RouterKeygen.cfv");
FileOutputStream fos = new FileOutputStream(OutputFilesNames.CFV_NAME);
fos.write(Stage4.version);
fos.write(digest);
fos.close();
Expand Down

0 comments on commit 9cde2e4

Please sign in to comment.