JSFiddle - React, Tailwind, and code Playground
HTML
<h1>
Does it have CIA hidden data?
</h1>
<h2 style="color:red;">
<div id="result"></div>
</h2>
<input type="file" />
JavaScript
var NULL_BYTE_COUNT = 30;
document.querySelector('input').addEventListener('change', function() {
var reader = new FileReader();
reader.onload = function() {
var array = new Uint8Array(this.result);
var nullByteCount = 0;
var numHiddenFiles = 0;
for (var i = 0; i < array.length; i++) {
var inc = array[i] === 0x0 ? 1 : -1;
nullByteCount = Math.max(nullByteCount + inc, 0);
if (nullByteCount === NULL_BYTE_COUNT) {
numHiddenFiles++;
nullByteCount = 0;
}
}
var answer = "No, try another file.";
if (numHiddenFiles > 0) {
answer = "Yes, there are " + numHiddenFiles + " chunks of hidden data.";
}
document.getElementById("result").innerHTML = answer;
}
reader.readAsArrayBuffer(this.files[0]);
}, false);