Questions tagged [binary-data]

Binary-data is information stored using a two character alphabet (typically written using 0 and 1)

Binary Data is information which is stored using a two character alphabet. For example, the number 42 could be stored as its base-2 representation: 101010.

In modern computers, almost all data is ultimately represented in binary form.

To be useful, the writer and reader of binary data must have a pre-agreed format (e.g. a file consisting of a 32-bit, two's compliment integer followed by three IEEE 754 floating point numbers).

The term is usually used to distinguish data stored in this way against data stored using a textual encoding. For example, the digits of 42 in base-10 (4 and 2) may be represented using ASCII as 00110100 and 00110010. Whether this is considered binary data or not depends on the task at hand; a chat client would consider messages as textual data, but the communication protocol it is built on may consider the same messages as arbitrary binary data.

1585 questions
38
votes
2 answers

how to get hexdump of a structure data

.... finalize(char *hdrs, sendip_data *headers[], int index, sendip_data *data, sendip_data *pack) { ........ For debugging purposes I want a hex dump of the data and pack structures, which are of type sendip_data, a really…
Udit Gupta
  • 3,162
  • 11
  • 43
  • 71
38
votes
10 answers

Calculating Binary Data Similarity

I've seen a few questions here related to determining the similarity of files, but they are all linked to a particular domain (images, sounds, text, etc). The techniques offered as solutions require knowledge of the underlying file format of the…
Chad Birch
  • 73,098
  • 23
  • 151
  • 149
35
votes
3 answers

best approach to design a rest web service with binary data to be consumed from the browser

I'm developing a json rest web service that will be consumed from a single web page app built with backbone.js This API will let the consumer upload files related to some entity, like pdf reports related to a project Googling around and doing some…
opensas
  • 60,462
  • 79
  • 252
  • 386
34
votes
2 answers

Prune binary data from a git repository after the fact

I accidentally committed some large binary data into some commits. Since then I've updated my .gitignore, and those files are no longer being committed. But I'd like to go back into the older commits and selectively prune out this data from the…
Myrddin Emrys
  • 42,126
  • 11
  • 38
  • 51
34
votes
2 answers

convert binary string to numpy array

Assume I have the string: my_data = '\x00\x00\x80?\x00\x00\x00@\x00\x00@@\x00\x00\x80@' Where I got it is irrelevant, but for the sake of having something concrete, assume I read it from a binary file. I know my string is the binary representation…
mgilson
  • 300,191
  • 65
  • 633
  • 696
33
votes
10 answers

Space-efficient algorithm for finding the largest balanced subarray?

given an array of 0s and 1s, find maximum subarray such that number of zeros and 1s are equal. This needs to be done in O(n) time and O(1) space. I have an algo which does it in O(n) time and O(n) space. It uses a prefix sum array and exploits the…
vastutsav
  • 532
  • 6
  • 11
33
votes
1 answer

Meaning of a Common String In Executables?

There appear to be some similar-looking long alphanumeric strings that commonly occur in Mach-O 64 bit executables and ELF 64-bit LSB executables among other symbols that are not alphanumeric: cat /bin/bash | grep -c "AWAVAUATSH" has 181 results,…
seewalker
  • 1,123
  • 10
  • 18
33
votes
9 answers

vector vs string for binary data

Which is a better c++ container for holding and accessing binary data? std::vector or std::string Is one more efficient than the other? Is one a more 'correct' usage?
kalaxy
  • 1,608
  • 1
  • 14
  • 14
29
votes
2 answers

Saving a Uint8Array to a binary file

I am working on a web app that opens binary files and allows them to be edited. This process is basically ondrop -> dataTransfer.files[0] -> FileReader -> Uint8Array Essentially, I want to be able to save the modified file back as a binary file.…
bryc
  • 12,710
  • 6
  • 41
  • 61
29
votes
11 answers

How to convert integer number into binary vector?

How to convert an integer number into binary vector using R? For example : number <- 11 [1] 1 0 1 1 what is the fastest possible method of conversion (using R code or some existing functions from packages) if I need to convert whole vector of…
Qbik
  • 5,885
  • 14
  • 62
  • 93
28
votes
2 answers

Python search and replace in binary file

I am trying to search and replace some of the text (eg 'Smith, John') in this pdf form file (header.fdf, I presumed this is treated as binary file): '%FDF-1.2\n%\xe2\xe3\xcf\xd3\n1 0 obj\n<><
ajo
  • 1,045
  • 4
  • 15
  • 30
27
votes
2 answers

Convert Binary.toString('encode64') back to Binary

I've seen several tutorial explaining how to convert binary image into encode64 representations: var image = new Buffer(bl.toString(), 'binary').toString('base64'); My question is, how to return this string representation, back to it's buffer's…
ariefbayu
  • 21,849
  • 12
  • 71
  • 92
27
votes
10 answers

How do I implement hex2bin()?

I need to communicate between Javascript and PHP (I use jQuery for AJAX), but the output of the PHP script may contain binary data. That's why I use bin2hex() and json_encode() on PHP side. How do I convert the hexadecimal string in binary string,…
MartyIX
  • 27,828
  • 29
  • 136
  • 207
27
votes
2 answers

Hamming distance on binary strings in SQL

I have a table in my DB where I store SHA256 hashes in a BINARY(32) column. I'm looking for a way to compute the Hamming distance of the entries in the column to a supplied value, i.e. something like: SELECT * FROM table ORDER BY…
CAFxX
  • 28,060
  • 6
  • 41
  • 66
27
votes
3 answers

Transfer raw binary with apache commons-net FTPClient?

UPDATE: Solved I was calling FTPClient.setFileType() before I logged in, causing the FTP server to use the default mode (ASCII) no matter what I set it to. The client, on the other hand, was behaving as though the file type had been properly set.…
Chris Suter
  • 1,338
  • 2
  • 9
  • 9