Forensics · 36 tools · nothing uploads

Byte frequency & chi-square

Count how often each of the 256 byte values appears in a file and compare the distribution to uniform random. A chi-square test, not a verdict.

Input

Byte frequency & chi-square counts every byte value in a file and measures how far the spread sits from uniform. The table lists every value in byte order with its count and percentage; a footnote line weighs the statistic against 293, the 0.05 critical value. No p-value is computed; a flat spread fits compressed, encrypted and random bytes.

Questions

What does the chi-square number tell me?

How far the file's byte distribution sits from a uniform one. Each of the 256 byte values is counted, the expected count is the file length divided by 256, and the statistic is the sum of (observed minus expected) squared over expected, with 255 degrees of freedom. Small means the bytes are spread evenly. Large means some values dominate, which is what text, code and structured formats look like.

Where does the cut-off of 293 come from?

It is the well-known rough 0.05 critical value for 255 degrees of freedom, used as a rule of thumb. Below it the report says the file is close to a uniform distribution, consistent with random, compressed or encrypted bytes. Above it, the file is far from uniform, consistent with structured, text or low-entropy data. No p-value is computed, so treat 293 as a signpost rather than a threshold to quote in a finding.

Does a uniform result mean the file is encrypted?

No. Compressed archives, media streams, random padding and encrypted blobs all flatten the byte distribution, and this statistic cannot separate them. It also says nothing about which algorithm was used or whether a key exists. Use it to decide that a region deserves attention, then identify it with Detect file type or Scan for embedded files.

What does the byte values table show?

All 256 byte values, in byte order, each with its hex value, its count and its share of the file as a percentage. A footnote line under the table reports how many of the 256 possible values appear at all, plus the chi-square statistic and its verdict. A file where 0x00 or 0x20 dominates is padded or textual; a file where every value sits close to 0.39 percent each is flat.

Why do I only get "empty file"?

The file has zero bytes. There is nothing to count and no distribution to compare against, so the tool reports the file name and "empty file" rather than dividing by zero and printing a statistic that means nothing. If you expected content, the file was truncated, emptied or never written; compare its size against a known good copy.

Which tool should I run next?

Entropy analysis, if you want the same question answered per region rather than for the whole file. Chi-square here is one number for the entire input, so a small encrypted blob inside a large text file barely moves it. Entropy analysis breaks the file into blocks and reports each one, which is how you find the boundary.

Related Forensics tools