Binary Raw - Docs
    Preparing search index...

    Function shannonEntropy

    • Calculates the Shannon entropy of a byte range.

      Complexity: O(n) time, O(1) additional space (256 fixed counters).

      Parameters

      • buffer: Uint8Array

        The complete file buffer

      • range: ByteRange

        Range to calculate (start, end, length)

      • useCache: boolean = false

        If true, caches results for repeated calls

      Returns EntropyResult

      EntropyResult with entropy, classification and statistics

      const result = shannonEntropy(buffer, Range.create(Offset.create(0), Offset.create(1023)));
      console.log(result.entropy); // → 7.94
      console.log(result.classification); // → "encrypted"