This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
1
Is there a good way to have a user upload a hex file, traverse it for a specific hex string, and then edit the next 2 bytes?
Post Body
IE: user uploads a hex file. I search for “0A 1B CC 04”, find it, then replace the next two bytes and output the new hex.
This is what I have but it is VERY slow
<!DOCTYPE HTML>
<html>
<head>
<title>Reading Binary Data with the File API and JavaScript</title>
</head>
<body>
<input id="browseOpen" type="file"/>
<textarea id="derp">
</textarea>
<input type="button" id="TestBtn" value="derp!"/>
<script type="text/javascript">
let fileData;
document.getElementById('TestBtn').style.display = "none";
var fileInput = document.getElementById("browseOpen");
var fileInput = document.getElementById("browseOpen");
fileInput.onchange = function () {
var fr = new FileReader();
fr.onloadend = function () {
var result = this.result;
var hex = "";
for (var i = 0; i < this.result.length; i ) {
var byteStr = result.charCodeAt(i).toString(16);
if (byteStr.length < 2) {
byteStr = "0" byteStr;
}
hex = " " byteStr;
}
//alert(hex);
fileData = hex;
document.getElementById('TestBtn').style.display = "";
};
fr.readAsBinaryString(this.files[0]);
};
document.getElementById('TestBtn').addEventListener("click", test);
function test(){
//document.getElementById('derp').value = fileData.replace('34 00 00 00 ac db', 'shit');
}
</script>
</body>
</html>
Author
Account Strength
100%
Account Age
13 years
Verified Email
Yes
Verified Flair
No
Total Karma
26,663
Link Karma
8,214
Comment Karma
18,430
Profile updated: 4 days ago
Posts updated: 8 months ago
Subreddit
Post Details
We try to extract some basic information from the post title. This is not
always successful or accurate, please use your best judgement and compare
these values to the post title and body for confirmation.
- Posted
- 3 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnjavasc...