Skip to content

Commit

Permalink
Several small changes and started working on Hash Verification.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnimeshShaw committed May 9, 2017
1 parent 229e470 commit 2c36879
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 63 deletions.
Binary file modified .gradle/2.10/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/outputFileStates.bin
Binary file not shown.
Binary file modified .gradle/2.10/taskArtifacts/taskArtifacts.bin
Binary file not shown.
8 changes: 8 additions & 0 deletions .nb-gradle-properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<gradle-project-properties>
<!--DO NOT EDIT THIS FILE! - Used by the Gradle plugin of NetBeans.-->
<license-header>
<name>apache20</name>
<property name="organization">Uchiha Systems</property>
</license-header>
</gradle-project-properties>
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ task wrapper(type: Wrapper) {

jar {
baseName = 'PsychoHasher'
version = '1.0-Alpha'
version = '1.1-Beta'
manifest {
attributes 'Main-Class': 'com.uchihasystems.psychohasher.gui.PsychoHasherGui'
}
}

task fatJar(type: Jar) {
manifest.from jar.manifest
classifier = '1.0-Alpha-FAT'
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
manifest.from jar.manifest
classifier = '1.1-Beta-FAT'
from {
configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}

artifacts {
Expand Down
4 changes: 0 additions & 4 deletions phasher-exec.log
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
04/Apr/2017 09:44:48,093- PsychoHasherGui: Application Started.
04/Apr/2017 10:16:48,442- PsychoHasherGui: Application Started.
04/Apr/2017 10:36:27,549- PsychoHasherGui: Application Started.
14/Apr/2017 22:57:41,257- PsychoHasherGui: Application Started.
Binary file added releases/PsychoHasher-1.1-Beta-FAT.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/main/java/com/uchihasystems/psychohasher/HashType.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.uchihasystems.psychohasher;

/**
* Enum that contains all the HashType Algo types supported by this application.
* <p>Enum that contains all the HashType Algo types supported by this application.</p>
*
* @author <b>Psycho_Coder </b> (<em>Animesh Shaw</em>)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
public class HashingUtils {

/**
* Converts array of bytes to hex string.
* <p>
* Converts array of bytes to hex string.</p>
*
* @param bytes Byte Array to be converted to Hex String.
* @return Returns the hex string for {@code bytes} array.
Expand Down
110 changes: 72 additions & 38 deletions src/main/java/com/uchihasystems/psychohasher/gui/PsychoHasherGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
*/
public class PsychoHasherGui extends JFrame {

private static final long serialVersionUID = 2784748735519288623L;

private final int DEF_WIDTH = 800;
private final int DEF_HEIGHT = 500;

Expand All @@ -95,9 +97,9 @@ public class PsychoHasherGui extends JFrame {

private JEditorPane welcomePane;

private final JPanel mainPanel;
private JPanel mainPanel;
private JPanel resultPanel;
private JPanel welcome, hashText, hashFiles, hashFilesGroup;
private JPanel welcome, hashText, hashFiles, hashFilesGroup, hashVerify;

private Clipboard clipBrd;

Expand Down Expand Up @@ -151,35 +153,29 @@ public class PsychoHasherGui extends JFrame {
/**
* Builds the GUI and Initializes the components.
*
* @throws HeadlessException
* @throws HeadlessException Nothing Much to Say Indeed!
*/
public PsychoHasherGui() throws HeadlessException {
mainPanel = new JPanel(new BorderLayout());

setSize(new Dimension(DEF_WIDTH, DEF_HEIGHT));
setResizable(false);
setAlwaysOnTop(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLocationRelativeTo(null);
setTitle("PsychoHasher - All Purpose Hashing tool");
setContentPane(mainPanel);
setLayout(new BorderLayout());
setIconImage(new ImageIcon(this.getClass().getClassLoader().getResource("Hash.png")).getImage());
initComponents();
}

private void initComponents() {
try {/*
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}*/
try {
mainPanel = new JPanel(new BorderLayout());

setSize(new Dimension(DEF_WIDTH, DEF_HEIGHT));
setResizable(false);
setAlwaysOnTop(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLocationRelativeTo(null);
setTitle("PsychoHasher - All Purpose Hashing tool");
setContentPane(mainPanel);
setLayout(new BorderLayout());
setIconImage(new ImageIcon(this.getClass().getClassLoader().getResource("Hash.png")).getImage());

UIManager.setLookAndFeel("com.jtattoo.plaf.texture.TextureLookAndFeel");
} catch (ClassNotFoundException | InstantiationException | UnsupportedLookAndFeelException | IllegalAccessException ex) {
logger.error("Problem with LAF", ex);
logger.error("Problem with Look And Fell.", ex);
}

initGlobalDec();
Expand All @@ -189,7 +185,8 @@ private void initComponents() {
}

/**
* Global declaration of Reusable components
* <p>
* Global declaration of Reusable components</p>
*/
private void initGlobalDec() {
resultPanel = new JPanel();
Expand All @@ -199,7 +196,8 @@ private void initGlobalDec() {
}

/**
* Reusable Result Panel to be used in different tabs for different ops.
* <p>
* Reusable Result Panel to be used in different tabs for different ops</p>
*/
private void createResultPanel() {
resultPanel.setBorder(BorderFactory.createTitledBorder("Select Type of "
Expand All @@ -209,7 +207,7 @@ private void createResultPanel() {

resultTxtArea = new JTextArea();
resultTxtArea.setEditable(false);
resultTxtArea.setWrapStyleWord(false);
resultTxtArea.setWrapStyleWord(true);
scrollPaneResult = new JScrollPane(resultTxtArea,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
Expand Down Expand Up @@ -238,17 +236,20 @@ private void createResultPanel() {
}

/**
* Create Tabbed Pane
* <p>
* Create Tabbed Pane</p>
*/
private void createMainTabbedPane() {

/**
* Initialize the panels to be used in the tabbed pane.
* <p>
* Initialize the panels to be used in the tabbed pane.</p>
*/
welcome = new JPanel(new FlowLayout());
welcome = new JPanel();
hashText = new JPanel();
hashFiles = new JPanel();
hashFilesGroup = new JPanel();
hashVerify = new JPanel();

/**
* Initialize tabbed pane and create tabs
Expand All @@ -258,6 +259,8 @@ private void createMainTabbedPane() {
tabbedPane.addTab("Hash Text", hashText);
tabbedPane.addTab("Hash Files", hashFiles);
tabbedPane.addTab("Hash Files Group", hashFilesGroup);
//tabbedPane.addTab("Verify Hashes", hashVerify);

tabbedPane.addChangeListener((ChangeEvent e) -> {
switch (tabbedPane.getSelectedIndex()) {
case 0:
Expand Down Expand Up @@ -285,17 +288,22 @@ private void createMainTabbedPane() {
createWelcomeTab();
/* ---Welcome Tab ends--- */

/* ---HashText tab Starts--- */
/* ---HashText tab Starts--- */
createHashTextTab();
/* ---HashText tab ends--- */

/* ---HashFiles tab Starts--- */
/* ---HashFiles tab Starts--- */
createHashFilesTab();
/* ---HashFiles tab ends--- */

/* ---HashDisks tab Starts--- */
/* ---HashFilesGrounp tab Starts--- */
createHashFilesGroupTab();
/* ---HashDisks tab ends--- */

/* ---Verifyhash tab Starts--- */
createVerifyHashTab();
/* ---Verify tab ends--- */

}

private void createWelcomeTab() {
Expand All @@ -308,7 +316,7 @@ private void createWelcomeTab() {
welcomePane.setPage(this.getClass().getClassLoader()
.getResource("welcome.html"));
} catch (IOException ex) {
logger.debug("Resource welcome.html not found", ex);
logger.error("Resource welcome.html not found", ex);
}
welcome.add(welcomePane);
}
Expand Down Expand Up @@ -359,6 +367,9 @@ private void createHashTextTab() {

}

/**
* Multiple / Single File Hashing.
*/
private void createHashFilesTab() {
hashFiles.setLayout(null);

Expand Down Expand Up @@ -636,6 +647,9 @@ public boolean isCellEditable(int row, int column) {

}

/**
* File Hashing Progress Dialog.
*/
private void createHashingProgressDialog() {
setEnabled(false);
fileHasherDialog = new JDialog(this);
Expand Down Expand Up @@ -700,7 +714,7 @@ public HashFileTask(final LinkedList<File> filesToHash,

private void failIfInterrupted() throws InterruptedException {
if (Thread.currentThread().isInterrupted()) {
logger.debug("Interrupted while hashing files");
logger.error("Interrupted while hashing files");
throw new InterruptedException("Interrupted while hashing files");
}
}
Expand All @@ -722,7 +736,7 @@ protected LinkedList<String> doInBackground() throws Exception {
hashes.add(HashingUtils.getFileHash(f, hashType));
} else {
publish("Permission Denied. Unable to Hash file - " + f.getName());
logger.debug("No permission to read file" + f.getName());
logger.error("No permission to read file" + f.getName());
hashes.add("N/A");
}
}
Expand All @@ -734,18 +748,21 @@ protected void process(List<String> chunks) {
chunks.stream().map((str) -> {
txtArea.append(str);
return str;
}).forEach((_item) -> {
}).forEach((item) -> {
txtArea.append("\n");
});
}

@Override
protected void done() {
txtArea.append("Hash Computation Complete");
txtArea.append("\nHash Computation Complete");
}

}

/**
* Hashing Grouped Files for single Hash.
*/
private void createHashFilesGroupTab() {
hashFilesGroup.setLayout(null);

Expand Down Expand Up @@ -954,6 +971,10 @@ private void createHashFilesGroupTab() {

}

/**
* Class to hash group of files array in a different thread and set the
* progress.
*/
private class HashGroupFilesTask extends SwingWorker<String, String> {

private final Enumeration<File> filesToHash;
Expand Down Expand Up @@ -988,7 +1009,7 @@ public HashGroupFilesTask(final Enumeration<File> filesToHash, int fileCount,
*/
private void failIfInterrupted() throws InterruptedException {
if (Thread.currentThread().isInterrupted()) {
logger.debug("Interrupted while hashing files");
logger.error("Interrupted while hashing files");
throw new InterruptedException("Interrupted while hashing files");
}
}
Expand All @@ -1014,7 +1035,7 @@ protected String doInBackground() throws Exception {
permErr = true;
publish("Permission Denied. Unable to create hash for "
+ "the said file group - " + f.getName());
logger.debug("No permission to read file" + f.getName());
logger.error("No permission to read file" + f.getName());
break;
}

Expand Down Expand Up @@ -1061,6 +1082,19 @@ protected void done() {

}

/**
* <p>
* Hash Verification Tab.
* </p>
*/
private void createVerifyHashTab() {

}

/**
* <p>
* Creating the StatusBar</p>
*/
private void createStatusBar() {
statusBar = new JToolBar(SwingConstants.HORIZONTAL);
statusBar.setBorder(BorderFactory.createBevelBorder(
Expand Down
Binary file modified src/main/resources/Hash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Configuration status="ERROR">
<Appenders>
<RollingFile fileName="phasher-exec.log"
filePattern="phasher-exec-%d{yyyy-MM-dd}-%i.log" name="RollingFile">
filePattern="phasher-exec-%d{yyyy-MM-dd}-%i.log" name="RollingFile">
<PatternLayout>
<pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS}- %c{1}: %m%n</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="1 KB"/>
<SizeBasedTriggeringPolicy size="10 KB"/>
</Policies>
<DefaultRolloverStrategy max="4"/>
</RollingFile>
</Appenders>
<Loggers>
<Logger additivity="false" level="debug" name="root">
<appender-ref level="debug" ref="RollingFile"/>
<Logger additivity="false" level="error" name="root">
<appender-ref level="error" ref="RollingFile"/>
</Logger>
<Root additivity="false" level="debug">
<Root additivity="false" level="error">
<AppenderRef ref="RollingFile"/>
</Root>
</Loggers>
Expand Down
7 changes: 1 addition & 6 deletions src/main/resources/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ <h2>Current Features</h2>
<li>Compute hash value of text string.</li>
<li>Compute hash value of individual files or files in a folder.</li>
<li>Compute Single hash for group of files or folder.</li>
</ul>
<h2>ToDo</h2>
<ul>
<li>Add an option to compute hash for logical volumes.</li>
<li>Add Verify hashes section.</li>
</ul>
</ul>
</body>
</html>

0 comments on commit 2c36879

Please sign in to comment.