summaryrefslogtreecommitdiffstats
path: root/test/hash-file.html
diff options
context:
space:
mode:
Diffstat (limited to 'test/hash-file.html')
-rw-r--r--test/hash-file.html29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/hash-file.html b/test/hash-file.html
index 2d30fe0..5b45607 100644
--- a/test/hash-file.html
+++ b/test/hash-file.html
@@ -1,8 +1,23 @@
<script src="../src/sha.js"></script>
<input type="file" id="files" name="file" />
+<p>
<div id="progress"></div>
+<style>
+ .correct
+ {
+ color: #00FF00;
+ background-color: #FFFFFF;
+ }
+
+ .incorrect
+ {
+ color: #FF0000;
+ background-color: #FFFFFF;
+ }
+</style>
+
<script>
// How many bytes to read per chunk
var chunkSize = Math.pow(10, 5)
@@ -47,6 +62,18 @@
if (stop == file.size) {
result = hasher.getHash('HEX')
progress.innerHTML = result
+
+ // Allow testing on project license file
+ if (file.name == 'LICENSE') {
+ progress.innerHTML += ''
+
+ // Compare with sha384sum util
+ if (result == '25490ec88947b64b51e4bd1bcd52e19131c4ae324e4b5d12b17451eaf98121fde440204cb62ed5a1bd44ebff97dec2bd') {
+ progress.innerHTML += '<p>License hash comparison: <span class="correct">PASS</span>'
+ } else {
+ progress.innerHTML += '<p>License hash comparison: <span class="incorrect">FAIL</span>'
+ }
+ }
} else {
readFile(hasher, file, start + chunkSize, stop + chunkSize)
}
@@ -71,5 +98,7 @@
readFile(hasher, file, 0, chunkSize)
}
+ // Trigger file hash
document.getElementById('files').addEventListener('change', handleFileSelect, false)
+
</script>