In-Browser File Generation, Service Worker Streaming and SHA-256 Architecture: Questions and Answers
Engineering reference covering Technical Questions and Answers on deterministic Mulberry32 PRNG synthesis, Web Worker memory assembly, Service Worker ReadableStream chunking up to 1 GB, and Web Crypto SHA-256 verification across all 54 formats, how each format works at the byte level, how our deterministic generator builds and verifies them, and how to test them in QA pipelines.
Format hubs covered on this reference page
Part 1: Binary signatures, headers and specification rules
- 1. How does the SampleTestFiles generator construct a deterministic .avro (Avro) file of an exact byte size?
- Starting from a minimum valid size of 757 bytes (in steps of 1 byte), the generator writes the 4F 62 6A 01 signature and an Avro Object Container File starting with magic bytes 4F 62 6A 01 ('Obj\x01'), a file header map containing the JSON schema ('avro.schema') and codec ('avro.codec'), and data blocks separated by 16-byte sync markers, then hits the exact byte count by encoding variable-length ZigZag integers and UTF-8 string records across sync-marked data blocks to match the exact byte size.
- 2. How does the SampleTestFiles generator construct a deterministic .bin (BIN) file of an exact byte size?
- Starting from a minimum valid size of 1 bytes (in steps of 1 byte), the generator writes the None signature and high-entropy deterministic pseudo-random byte stream generated via a seeded 32-bit PRNG with no compressible repetition, then hits the exact byte count by emitting the exact requested number of PRNG bytes from 1 byte up to 1,073,741,824 bytes.
- 3. How does the SampleTestFiles generator construct a deterministic .bmp (BMP) file of an exact byte size?
- Starting from a minimum valid size of 58 bytes (in steps of 1 byte), the generator writes the 42 4D signature and 14-byte BITMAPFILEHEADER starting with 42 4D ('BM'), 4-byte little-endian file size, pixel data offset, 40-byte BITMAPINFOHEADER, and bottom-up BGR pixel rows padded to 4-byte multiples, then hits the exact byte count by sizing the uncompressed BGR pixel grid or header gap before the pixel array offset declared at byte 10.
- 4. How does the SampleTestFiles generator construct a deterministic .css (CSS) file of an exact byte size?
- Starting from a minimum valid size of 220 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and W3C Cascading Style Sheets rulesets consisting of selectors, declaration blocks { property: value; }, @media queries, and :root custom properties (--var), then hits the exact byte count by generating deterministic utility class rules and /* ... */ CSS comments to reach the exact byte count.
- 5. How does the SampleTestFiles generator construct a deterministic .csv (CSV) file of an exact byte size?
- Starting from a minimum valid size of 201 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and RFC 4180 plain-text rows separated by CRLF or LF, fields delimited by commas (0x2C), and fields containing commas/quotes/newlines enclosed in double quotes with internal quotes doubled (""), then hits the exact byte count by generating sequential tabular records with deterministic numeric and string fields calibrated so the final row lands on the exact target byte count.
- 6. How does the SampleTestFiles generator construct a deterministic .docx (DOCX) file of an exact byte size?
- Starting from a minimum valid size of 37,888 bytes (in steps of 1 byte), the generator writes the 50 4B 03 04 signature and an Open Packaging Conventions (OPC) ZIP archive containing [Content_Types].xml, _rels/.rels, word/document.xml (w:body, w:p, w:r, w:t), and word/styles.xml, then hits the exact byte count by sizing embedded media or XML comment/paragraph structures inside the ZIP container and recomputing the central directory CRC-32 and byte offsets.
- 7. How does the SampleTestFiles generator construct a deterministic .eml (EML) file of an exact byte size?
- Starting from a minimum valid size of 420 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and IETF RFC 5322 internet message text containing header fields (From, To, Subject, Date, Message-ID, MIME-Version: 1.0, Content-Type) separated from the body or multipart MIME boundary blocks by a blank CRLF line, then hits the exact byte count by expanding message body paragraphs or MIME multipart sections with CRLF line folding to hit the exact byte size.
- 8. How does the SampleTestFiles generator construct a deterministic .epub (EPUB) file of an exact byte size?
- Starting from a minimum valid size of 3,072 bytes (in steps of 1 byte), the generator writes the 50 4B 03 04 signature and an IDPF/W3C Open Container Format (OCF) ZIP archive starting with an uncompressed 20-byte mimetype entry ('application/epub+zip' at offset 38), META-INF/container.xml, an OPF package document (.opf), and XHTML content chapters, then hits the exact byte count by sizing XHTML chapter text and package resources inside the OCF ZIP container while preserving the uncompressed offset-30 mimetype header.
- 9. How does the SampleTestFiles generator construct a deterministic .flac (FLAC) file of an exact byte size?
- Starting from a minimum valid size of 185 bytes (in steps of 1 byte), the generator writes the 66 4C 61 43 signature and 4-byte ASCII signature 66 4C 61 43 ('fLaC') followed by metadata blocks (mandatory 34-byte STREAMINFO block containing sample rate, channels, total samples, and 16-byte MD5 signature of the unencoded PCM data, plus PADDING/VORBIS_COMMENT) and compressed audio frames, then hits the exact byte count by sizing a standard FLAC metadata PADDING block (block type 1) before the first audio frame.
- 10. How does the SampleTestFiles generator construct a deterministic .geojson (GeoJSON) file of an exact byte size?
- Starting from a minimum valid size of 120 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and IETF RFC 7946 UTF-8 JSON document containing a FeatureCollection or Feature with Geometry objects (Point, LineString, Polygon, MultiPolygon) in WGS84 (EPSG:4326) [longitude, latitude] coordinate order, then hits the exact byte count by generating valid geographic Feature objects with properties and coordinate rings calibrated to the exact byte length.
- 11. How does the SampleTestFiles generator construct a deterministic .gif (GIF) file of an exact byte size?
- Starting from a minimum valid size of 874 bytes (in steps of 1 byte), the generator writes the 47 49 46 38 39 61 signature and 6-byte header (47 49 46 38 39 61 'GIF89a'), Logical Screen Descriptor, Global Color Table (up to 256 RGB entries), Netscape 2.0 loop extension, Graphic Control Extension, LZW-compressed image data sub-blocks, and trailer byte 0x3B (;), then hits the exact byte count by inserting GIF89a Comment Extension sub-blocks (21 FE ...) before the final 0x3B trailer byte.
- 12. How does the SampleTestFiles generator construct a deterministic .gltf (glTF) file of an exact byte size?
- Starting from a minimum valid size of 1,024 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and Khronos Group glTF 2.0 JSON scene description ('asset': {'version': '2.0'}, 'scenes', 'nodes', 'meshes', 'accessors', 'bufferViews', and 'buffers' with embedded data:application/octet-stream;base64,... vertex geometry), then hits the exact byte count by sizing the JSON scene metadata and buffer descriptors to hit the exact byte count while passing Khronos glTF 2.0 schema validation.
- 13. How does the SampleTestFiles generator construct a deterministic .gpx (GPX) file of an exact byte size?
- Starting from a minimum valid size of 700 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and Topografix GPX 1.1 XML schema (<gpx version="1.1" creator="...">) containing waypoints (<wpt>), routes (<rte>), and tracks (<trk>/<trkseg>/<trkpt lat="..." lon="...">) with <ele> elevation and ISO 8601 <time> elements, then hits the exact byte count by generating sequential GPS trackpoints (<trkpt>) along a synthetic route to match the exact byte target.
- 14. How does the SampleTestFiles generator construct a deterministic .gz (GZ) file of an exact byte size?
- Starting from a minimum valid size of 35 bytes (in steps of 1 byte), the generator writes the 1F 8B 08 signature and IETF RFC 1952 stream starting with a 10-byte header (1F 8B 08, flags, 32-bit mtime, extra flags, OS byte), a DEFLATE-compressed payload (RFC 1951), and an 8-byte trailer containing the 32-bit CRC-32 and 32-bit uncompressed size modulo 2^32 (ISIZE), then hits the exact byte count by calibrating the uncompressed input stream or FEXTRA/FCOMMENT header fields so the compressed output plus 8-byte trailer lands on the exact byte size.
- 15. How does the SampleTestFiles generator construct a deterministic .html (HTML) file of an exact byte size?
- Starting from a minimum valid size of 700 bytes (in steps of 1 byte), the generator writes the 3C 21 44 4F 43 54 59 50 45 signature and WHATWG HTML5 document starting with <!DOCTYPE html>, <html lang="en">, <head> metadata, and semantic <body> elements (<main>, <section>, <table>, <article>), then hits the exact byte count by generating structured <section> and <p> content blocks inside <body> and HTML comments <!-- ... --> to hit the exact byte size.
- 16. How does the SampleTestFiles generator construct a deterministic .ico (ICO) file of an exact byte size?
- Starting from a minimum valid size of 1,024 bytes (in steps of 1 byte), the generator writes the 00 00 01 00 signature and 6-byte ICONDIR header (00 00 01 00 + 16-bit image count), one or more 16-byte ICONDIRENTRY records (width, height, bpp, byte size, offset), and embedded BMP (DIB without file header) or PNG payloads, then hits the exact byte count by embedding multi-resolution icon bitmaps (16x16, 32x32, 48x48) inside the directory container.
- 17. How does the SampleTestFiles generator construct a deterministic .ics (iCalendar) file of an exact byte size?
- Starting from a minimum valid size of 220 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and IETF RFC 5545 iCalendar plain text starting with BEGIN:VCALENDAR, VERSION:2.0, PRODID, one or more BEGIN:VEVENT ... END:VEVENT blocks (UID, DTSTAMP, DTSTART, DTEND, SUMMARY), and END:VCALENDAR with 75-octet CRLF line folding, then hits the exact byte count by adding deterministic VEVENT calendar entries or DESCRIPTION text folded at 75 octets to match the exact byte target.
- 18. How does the SampleTestFiles generator construct a deterministic .ini (INI) file of an exact byte size?
- Starting from a minimum valid size of 120 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and section headers enclosed in square brackets [section_name], key=value pairs, and semicolon (;) or hash (#) comment lines, then hits the exact byte count by adding numbered [section_N] blocks and key=value settings to match the exact byte target.
- 19. How does the SampleTestFiles generator construct a deterministic .jpg (JPG) file of an exact byte size?
- Starting from a minimum valid size of 632 bytes (in steps of 1 byte), the generator writes the FF D8 FF signature and ITU-T T.81 / JFIF stream starting with SOI (FF D8), APP0 JFIF marker (FF E0), quantization tables (FF DB), baseline DCT frame header (FF C0), Huffman tables (FF C4), entropy-coded scan (FF DA), and EOI trailer (FF D9), then hits the exact byte count by inserting spec-compliant JPEG COM (FF FE) comment segments before the SOS scan marker so the image decodes cleanly while hitting the exact byte target.
- 20. How does the SampleTestFiles generator construct a deterministic .js (JavaScript) file of an exact byte size?
- Starting from a minimum valid size of 700 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and ECMAScript source code (IANA text/javascript per RFC 9239) containing strict-mode functions, pure data arrays, and arithmetic helpers, then hits the exact byte count by expanding deterministic data arrays and /* ... */ block comments to reach the exact target byte length.
- 21. How does the SampleTestFiles generator construct a deterministic .json (JSON) file of an exact byte size?
- Starting from a minimum valid size of 136 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and IETF RFC 8259 UTF-8 text consisting of six structural tokens ({, }, [, ], :, ,), double-quoted strings with backslash escapes, IEEE 754 numbers, booleans (true, false), and null, then hits the exact byte count by sizing the array of deterministic record objects and adjusting the final record's string field length so the closing bracket ] and newline hit the exact byte count.
- 22. How does the SampleTestFiles generator construct a deterministic .jsonl (JSONL) file of an exact byte size?
- Starting from a minimum valid size of 37 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and newline-delimited UTF-8 stream where each LF-terminated line is an independent, self-contained JSON object with no outer array wrapper, then hits the exact byte count by emitting one compact JSON object per line until the exact byte budget is reached on the final newline.
- 23. How does the SampleTestFiles generator construct a deterministic .kml (KML) file of an exact byte size?
- Starting from a minimum valid size of 400 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and OGC KML 2.2 XML document (<kml xmlns="http://www.opengis.net/kml/2.2">) containing <Document>, <Placemark>, <Point>, <LineString>, and <Polygon> elements with lon,lat,alt coordinate tuples, then hits the exact byte count by adding <Placemark> waypoints and XML comments inside <Document> to hit the exact byte size.
- 24. How does the SampleTestFiles generator construct a deterministic .log (LOG) file of an exact byte size?
- Starting from a minimum valid size of 97 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and chronological plain-text server log lines in NCSA Combined / RFC 5424 syslog format with ISO timestamps, reserved RFC 5737 TEST-NET IP addresses (192.0.2.x, 198.51.100.x, 203.0.113.x), HTTP methods, status codes, and byte counts, then hits the exact byte count by appending sequential timestamped log entries so the final newline lands on the exact target byte count.
- 25. How does the SampleTestFiles generator construct a deterministic .m4a (M4A) file of an exact byte size?
- Starting from a minimum valid size of 929 bytes (in steps of 1 byte), the generator writes the 66 74 79 70 4D 34 41 20 at byte offset 4 signature and an ISO Base Media container starting with ftypM4A (66 74 79 70 4D 34 41 20) at byte offset 4, wrapping AAC-LC or Apple Lossless (ALAC) audio frames inside moov/mdat boxes with iTunes ilst metadata atoms, then hits the exact byte count by sizing an ISO Base Media 'free' box so the .m4a file matches the exact requested byte length.
Part 2: Internal container layout, padding and byte structure
- 1. How does the SampleTestFiles generator construct a deterministic .md (Markdown) file of an exact byte size?
- Starting from a minimum valid size of 120 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and UTF-8 plain text structured with ATX headings (#), fenced code blocks (```), pipe tables, ordered and unordered lists, and inline link syntax [label](url), then hits the exact byte count by repeating structured documentation sections, code blocks, and bullet lists to hit the exact UTF-8 byte count without splitting multi-byte sequences.
- 2. How does the SampleTestFiles generator construct a deterministic .mkv (MKV) file of an exact byte size?
- Starting from a minimum valid size of 5,363 bytes (in steps of 1 byte), the generator writes the 1A 45 DF A3 signature and an EBML container starting with 1A 45 DF A3 declaring DocType 'matroska', supporting unlimited video, audio, and subtitle tracks, chapter atoms, and attached fonts, then hits the exact byte count by sizing an EBML Void (0xEC) padding element inside the Matroska Segment so the file hits the exact byte count.
- 3. How does the SampleTestFiles generator construct a deterministic .mov (MOV) file of an exact byte size?
- Starting from a minimum valid size of 5,713 bytes (in steps of 1 byte), the generator writes the 66 74 79 70 71 74 20 20 at byte offset 4 signature and Apple QuickTime Movie container starting with ftypqt (66 74 79 70 71 74 20 20) at offset 4, followed by moov, trak, mdia, minf, stbl, mdat, and free atoms, then hits the exact byte count by sizing the QuickTime 'free' atom at the end of the container to match the exact target byte length.
- 4. How does the SampleTestFiles generator construct a deterministic .mp3 (MP3) file of an exact byte size?
- Starting from a minimum valid size of 953 bytes (in steps of 1 byte), the generator writes the 49 44 33 signature and an optional leading ID3v2 metadata tag (49 44 33 'ID3' with synchsafe 28-bit integer size) followed by MPEG-1 Audio Layer III frames starting with an 11-bit frame sync (FF FB) and a Xing/Info VBR header frame, then hits the exact byte count by sizing the ID3v2 padding area or appending exact-bitrate CBR MPEG frames to reach the target byte count.
- 5. How does the SampleTestFiles generator construct a deterministic .mp4 (MP4) file of an exact byte size?
- Starting from a minimum valid size of 5,725 bytes (in steps of 1 byte), the generator writes the 66 74 79 70 at byte offset 4 signature and ISO/IEC 14496-12 box hierarchy starting with ftyp (file type and brand compatibility), moov (movie header mvhd, video/audio tracks trak, sample table stbl), mdat (H.264/AAC elementary packets), and free (padding box), then hits the exact byte count by appending or sizing a standard ISO Base Media 'free' (0x66726565) padding box so the total file reaches the exact byte target without affecting playback.
- 6. How does the SampleTestFiles generator construct a deterministic .obj (OBJ) file of an exact byte size?
- Starting from a minimum valid size of 120 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and Wavefront plain-text 3D geometry definition listing vertex coordinates (v x y z), texture coordinates (vt u v), vertex normals (vn x y z), and 1-based polygonal faces (f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3), then hits the exact byte count by generating 3D mesh vertices, normals, faces, and # comment lines calibrated to the exact byte length.
- 7. How does the SampleTestFiles generator construct a deterministic .ods (ODS) file of an exact byte size?
- Starting from a minimum valid size of 4,096 bytes (in steps of 1 byte), the generator writes the 50 4B 03 04 signature and an OASIS OpenDocument Spreadsheet ZIP archive with an uncompressed mimetype entry at offset 30 and <table:table-row>/<table:table-cell> nodes in content.xml, then hits the exact byte count by adding typed <table:table-row> spreadsheet records and OpenDocument manifest entries to reach the exact byte target.
- 8. How does the SampleTestFiles generator construct a deterministic .odt (ODT) file of an exact byte size?
- Starting from a minimum valid size of 4,096 bytes (in steps of 1 byte), the generator writes the 50 4B 03 04 signature and an OASIS OpenDocument ZIP package where the very first entry at offset 30 is an uncompressed file named mimetype containing application/vnd.oasis.opendocument.text, followed by content.xml, styles.xml, and META-INF/manifest.xml, then hits the exact byte count by expanding <text:p> paragraphs inside content.xml and deterministic padding entries while keeping the first mimetype entry uncompressed at byte offset 30.
- 9. How does the SampleTestFiles generator construct a deterministic .pdf (PDF) file of an exact byte size?
- Starting from a minimum valid size of 1,125 bytes (in steps of 1 byte), the generator writes the 25 50 44 46 2D signature and numbered indirect objects (N 0 obj ... endobj), content streams compressed with FlateDecode, a byte-offset cross-reference table (xref), and a trailer dictionary ending with startxref and %%EOF, then hits the exact byte count by inserting syntactically valid % comment lines right before the cross-reference table so every byte offset in xref remains exact.
- 10. How does the SampleTestFiles generator construct a deterministic .png (PNG) file of an exact byte size?
- Starting from a minimum valid size of 116 bytes (in steps of 1 byte), the generator writes the 89 50 4E 47 0D 0A 1A 0A signature and 8-byte signature (89 50 4E 47 0D 0A 1A 0A) followed by length-type-data-CRC chunks: 13-byte IHDR header, zlib/DEFLATE-compressed IDAT pixel scanlines with filter bytes, optional tEXt metadata chunks, and a 12-byte IEND trailer, then hits the exact byte count by adding a spec-compliant ancillary tEXt chunk with a verified IEEE 802.3 CRC-32 checksum right before the IEND chunk.
- 11. How does the SampleTestFiles generator construct a deterministic .pptx (PPTX) file of an exact byte size?
- Starting from a minimum valid size of 36,864 bytes (in steps of 1 byte), the generator writes the 50 4B 03 04 signature and an OpenXML ZIP archive holding ppt/presentation.xml, individual slide trees under ppt/slides/slideN.xml, ppt/slideLayouts/, and DrawingML vector/text shapes measured in English Metric Units (1 inch = 914,400 EMUs), then hits the exact byte count by embedding slide content and media streams inside ppt/media/ within the ZIP container to match the exact byte target.
- 12. How does the SampleTestFiles generator construct a deterministic .rtf (RTF) file of an exact byte size?
- Starting from a minimum valid size of 150 bytes (in steps of 1 byte), the generator writes the 7B 5C 72 74 66 31 signature and 7-bit ASCII control words starting with a backslash (\rtf1\ansi\deff0), nested curly-brace groups {...}, a \fonttbl font table, and paragraph formatting tokens (\pard, \par), then hits the exact byte count by extending deterministic prose paragraphs and \par blocks inside the main document group before the final closing brace }.
- 13. How does the SampleTestFiles generator construct a deterministic .sql (SQL) file of an exact byte size?
- Starting from a minimum valid size of 414 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and ANSI SQL DDL and DML statements (CREATE TABLE, INSERT INTO ... VALUES ..., CREATE INDEX) with SQL -- comments and semicolon statement terminators, then hits the exact byte count by generating deterministic INSERT INTO rows and SQL comment blocks calibrated to the exact byte length.
- 14. How does the SampleTestFiles generator construct a deterministic .srt (SRT) file of an exact byte size?
- Starting from a minimum valid size of 60 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and SubRip plain-text subtitle cues consisting of a sequential 1-based integer index, a timestamp line using comma millisecond separators (HH:MM:SS,mmm --> HH:MM:SS,mmm), 1–2 lines of caption text, and a blank separator line, then hits the exact byte count by generating sequential timed subtitle cues across the timeline to reach the exact byte count.
- 15. How does the SampleTestFiles generator construct a deterministic .stl (STL) file of an exact byte size?
- Starting from a minimum valid size of 40 bytes (in steps of 1 byte), the generator writes the 73 6F 6C 69 64 signature and either an 80-byte binary header + 4-byte uint32 triangle count + N * 50-byte triangle records (12-byte normal vector + three 12-byte float32 vertices + 2-byte attribute count) or an ASCII 'solid ... facet normal ... endsolid' mesh, then hits the exact byte count by generating valid tessellated 3D triangle facets so 84 + (50 * triangle_count) or ASCII facet blocks match the target size.
- 16. How does the SampleTestFiles generator construct a deterministic .svg (SVG) file of an exact byte size?
- Starting from a minimum valid size of 300 bytes (in steps of 1 byte), the generator writes the 3C 73 76 67 signature and W3C XML vector graphic starting with <svg xmlns="http://www.w3.org/2000/svg" viewBox="..."> and geometric primitives (<rect>, <circle>, <path>, <g>, <text>), then hits the exact byte count by adding vector <rect>/<path> elements and XML comments inside the <svg> root element to match the exact byte target.
- 17. How does the SampleTestFiles generator construct a deterministic .tar (TAR) file of an exact byte size?
- Starting from a minimum valid size of 2,560 bytes (in steps of 512 bytes), the generator writes the 75 73 74 61 72 at byte offset 257 signature and sequential 512-byte blocks where each archived file is preceded by a 512-byte POSIX ustar header (magic 'ustar' 75 73 74 61 72 at byte offset 257, octal size/mtime/mode fields, and an 8-byte header checksum), terminated by at least two 512-byte zero blocks, then hits the exact byte count by sizing archived member payload and trailing 512-byte zero padding blocks in 512-byte increments.
- 18. How does the SampleTestFiles generator construct a deterministic .tiff (TIFF) file of an exact byte size?
- Starting from a minimum valid size of 268 bytes (in steps of 1 byte), the generator writes the 49 49 2A 00 signature and 8-byte header declaring byte order (49 49 2A 00 for little-endian 'II*' or 4D 4D 00 2A for big-endian 'MM*'), offset to the first Image File Directory (IFD), 12-byte tag entries (Width, Length, BitsPerSample, StripOffsets), and pixel strips, then hits the exact byte count by placing deterministic padding bytes between the pixel strip data and the IFD pointer offset.
- 19. How does the SampleTestFiles generator construct a deterministic .toml (TOML) file of an exact byte size?
- Starting from a minimum valid size of 200 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and TOML v1.0 configuration syntax with bracketed [table] and [[array_of_tables]] headers, key = "value" assignments, strongly typed arrays, and native RFC 3339 timestamps, then hits the exact byte count by generating [[records]] table entries and # comment lines to reach the exact target byte count.
- 20. How does the SampleTestFiles generator construct a deterministic .tsv (TSV) file of an exact byte size?
- Starting from a minimum valid size of 199 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and IANA text/tab-separated-values tabular text where columns are separated by horizontal tab characters (0x09) and rows by LF or CRLF, then hits the exact byte count by appending tab-delimited data rows with exact byte-length calculation on the final record.
- 21. How does the SampleTestFiles generator construct a deterministic .txt (TXT) file of an exact byte size?
- Starting from a minimum valid size of 210 bytes (in steps of 1 byte), the generator writes the None signature and raw unformatted UTF-8 character sequences terminated by LF (0x0A) or CRLF (0x0D 0x0A) newline bytes with no binary header, then hits the exact byte count by deterministic line generation calibrated to the exact final byte length ending cleanly with a newline character.
- 22. How does the SampleTestFiles generator construct a deterministic .vtt (WebVTT) file of an exact byte size?
- Starting from a minimum valid size of 384 bytes (in steps of 1 byte), the generator writes the 57 45 42 56 54 54 signature and W3C WebVTT file starting with the mandatory signature WEBVTT on line 1, followed by a blank line and timed cues using period millisecond separators (HH:MM:SS.mmm --> HH:MM:SS.mmm) and optional cue positioning settings, then hits the exact byte count by adding sequential WebVTT caption cues and NOTE comment blocks to hit the exact byte target.
- 23. How does the SampleTestFiles generator construct a deterministic .wav (WAV) file of an exact byte size?
- Starting from a minimum valid size of 48 bytes (in steps of 4 bytes), the generator writes the 52 49 46 46 ?? ?? ?? ?? 57 41 56 45 signature and a little-endian RIFF container (52 49 46 46 + size + 57 41 56 45 'WAVE') with a 16-byte 'fmt ' chunk (AudioFormat=1 for linear PCM, channels, sample rate, byte rate, block align, bits per sample) and a 'data' chunk holding raw PCM samples, then hits the exact byte count by sizing the PCM 'data' chunk or adding an ancillary RIFF 'JUNK' / 'LIST' chunk while keeping the 32-bit RIFF size field at offset 4 exact.
- 24. How does the SampleTestFiles generator construct a deterministic .webm (WebM) file of an exact byte size?
- Starting from a minimum valid size of 9,960 bytes (in steps of 1 byte), the generator writes the 1A 45 DF A3 signature and an EBML (Extensible Binary Meta Language) header starting with 1A 45 DF A3 declaring DocType 'webm', followed by a Segment containing Info, Tracks (VP8/VP9/AV1 video + Vorbis/Opus audio), Cues, and time-stamped Clusters, then hits the exact byte count by inserting a standard EBML Void element (ID 0xEC) encoded with an EBML variable-size integer (VINT) length.
- 25. How does the SampleTestFiles generator construct a deterministic .webp (WebP) file of an exact byte size?
- Starting from a minimum valid size of 518 bytes (in steps of 2 bytes), the generator writes the 52 49 46 46 ?? ?? ?? ?? 57 45 42 50 signature and a little-endian RIFF container (52 49 46 46 + 4-byte file size - 8 + 57 45 42 50 'WEBP') containing a VP8 (lossy), VP8L (lossless), or VP8X (extended/alpha/animated) chunk, then hits the exact byte count by appending an ancillary RIFF pad/metadata chunk with even-byte alignment and updating the master 32-bit RIFF size field at offset 4.
Part 3: In-browser generation, streaming and SHA-256 checksums
- 1. How does the SampleTestFiles generator construct a deterministic .xlsx (XLSX) file of an exact byte size?
- Starting from a minimum valid size of 3,684 bytes (in steps of 1 byte), the generator writes the 50 4B 03 04 signature and an OpenXML ZIP package containing xl/workbook.xml, xl/worksheets/sheet1.xml (<row> and <c> cell nodes), xl/sharedStrings.xml (deduplicated string table), and xl/styles.xml, then hits the exact byte count by populating deterministic worksheet rows and shared string records inside the ZIP container with valid CRC-32 central directory entries.
- 2. How does the SampleTestFiles generator construct a deterministic .xml (XML) file of an exact byte size?
- Starting from a minimum valid size of 156 bytes (in steps of 1 byte), the generator writes the 3C 3F 78 6D 6C signature and W3C XML 1.0 UTF-8 markup beginning with the XML declaration <?xml version="1.0" encoding="UTF-8"?>, a single root element, balanced start/end tags, attributes, and entity escapes (&, <, >, ", '), then hits the exact byte count by repeating structured <record> child elements and XML comments inside the root element to reach the exact byte count.
- 3. How does the SampleTestFiles generator construct a deterministic .yaml (YAML) file of an exact byte size?
- Starting from a minimum valid size of 150 bytes (in steps of 1 byte), the generator writes the UTF-8 text signature and YAML 1.2 human-readable data serialization using space-based indentation (never tabs), key: value mappings, hyphen-prefixed block sequences (- item), and # comments, then hits the exact byte count by adding deterministic block mapping items and # comment lines calibrated to the exact byte length.
- 4. How does the SampleTestFiles generator construct a deterministic .zip (ZIP) file of an exact byte size?
- Starting from a minimum valid size of 322 bytes (in steps of 1 byte), the generator writes the 50 4B 03 04 signature and PKWARE APPNOTE container consisting of Local File Headers (50 4B 03 04), DEFLATE or STORE payload data, Central Directory File Headers (50 4B 01 02), and an End of Central Directory record (50 4B 05 06) at the end of the file, then hits the exact byte count by adjusting archive member content and extra-field bytes with recomputed IEEE CRC-32 checksums and exact Central Directory offsets.
- 5. Why does SampleTestFiles generate files in the visitor's browser instead of storing 1,000+ large binaries on a server?
- Generating files locally in the browser via Web Workers and Service Workers allows us to offer exact byte sizes from 1 KB up to 1 GB (1,073,741,824 bytes) with zero server compute, zero database dependencies, and instant local assembly.
- 6. What is the Mulberry32 PRNG used inside the core generator module?
- Mulberry32 is a fast, deterministic 32-bit integer pseudo-random number generator that uses only 32-bit bitwise shifts and Math.imul so every JavaScript engine (V8, SpiderMonkey, JavaScriptCore) produces the exact same byte sequence.
- 7. Why does the generator avoid Math.sin, Math.cos, and Math.exp when building deterministic file bytes?
- IEEE 754 transcendental functions like Math.sin and Math.cos are not required by the ECMAScript specification to be bit-identical across different CPU architectures and browser engines, which would change the file's SHA-256 checksum across devices.
- 8. What is the 32 MB (33,554,432-byte) threshold in the download controller?
- Files of 32 MB or smaller are always assembled in a background Web Worker as an in-memory Blob and verified against their published SHA-256 hash using crypto.subtle.digest before saving.
- 9. How does the Service Worker (/sw.js) stream files from 50 MB to 1 GB straight to disk?
- When a page requests /__gen/f/<format>/<bytes>/<filename>, /sw.js responds with a synthetic HTTP 200 Response backed by a ReadableStream and Content-Disposition: attachment, yielding ~1 MB chunks directly to the browser's download manager.
- 10. How does the page verify that /sw.js is active before starting a 500 MB or 1 GB streamed download?
- The script the download controller registers /sw.js and fetches /__gen/ping with cache: 'no-store', confirming that the active Service Worker returns JSON version 'large-files-20261108' before enabling streaming.
- 11. Why does the page send a ping message to the Service Worker every 5 seconds during a large download?
- Browsers terminate idle Service Workers after roughly 30 seconds of inactivity; posting a keep-alive message over navigator.serviceWorker.controller every 5,000 ms keeps the worker alive while a 1 GB file streams to disk.
- 12. How does BroadcastChannel('stf-gen') report download progress back to the button label?
- While /sw.js streams chunks into the ReadableStream, it posts { id, state: 'progress', done, size } messages over the stf-gen BroadcastChannel so the download button updates its percentage (for example '42% · Cancel').
- 13. What happens when a visitor clicks a download button a second time while it says 'Cancel'?
- Clicking an active button with data-busy invokes job.cancel(), which terminates the background Web Worker immediately or closes the streaming download iframe.
- 14. Why is Service Worker streaming disabled on Safari and all browsers on iPhone and iPad?
- WebKit on macOS and iOS does not reliably hand a streamed Service Worker ReadableStream response to the system download manager, so our capability detector uses in-memory Web Worker generation on WebKit.
- 15. How does memoryLimit() calculate the largest safe in-memory file size when streaming is unavailable?
- It checks navigator.deviceMemory (when exposed by Chromium) and platform type, setting conservative ceilings of 64 MB on iOS, 128 MB on mobile devices or <=4 GB RAM machines, and 256 MB on desktop browsers without Service Worker streaming.
- 16. What are the .seed and .tpl files stored under /assets/gen/?
- They are compact, pre-encoded binary seed clips (such as H.264 720p/1080p keyframes, VP9 frames, MP3/AAC frames) and base OpenXML/EPUB templates that the in-browser generator loops and pads deterministically to construct valid media and Office files.
- 17. What is the curated binary pack?
- It is a compact binary fixture pack containing the pre-built curated samples (such as multi-page PDFs, form-field PDFs, and corrupted test fixtures) indexed by the checksum specification index.
- 18. What does the checksum specification index contain?
- It maps each of the 1,033 listed sample filenames to its exact generator specification (spec), exact byte count (bytes), and expected 64-character SHA-256 hash (sha256).
- 19. What happens if a Web Worker generates a file whose byte length or SHA-256 hash does not match specs.json?
- The create() function in the download controller throws a 'Checksum mismatch' or 'wrong size' error and refuses to save the file, preventing corrupted output from ever reaching your Downloads folder.
- 20. How does the file previewer preview a 100 MB text or CSV file without freezing the tab?
- It reads at most the first 65,536 bytes (TEXT_LIMIT = 64 KB) using Blob.slice(0, 65536) or an HTTP Range: bytes=0-65535 request, decodes UTF-8, and renders only the head of the file.
- 21. How does the JSON previewer highlight syntax without risking XSS injection?
- Instead of using innerHTML, showJson() tokenizes the text with a regular expression and appends document.createTextNode() and <span class='tok-...'> elements via DOM methods so file content is never parsed as HTML.
- 22. How does the CSV previewer detect whether a file uses comma, semicolon, or tab delimiters?
- It inspects the first line of the file and picks whichever delimiter (',', ';', or '\t') splits the header row into the largest number of columns before running an RFC 4180 state-machine parser on the first 25 data rows.
- 23. Why does /robots.txt include Disallow: /__gen/?
- Paths under /__gen/ are virtual browser-only endpoints intercepted by /sw.js to stream generated files; they do not exist on the static web server and should never be crawled by search engines.
- 24. How does the theme toggle remember light vs. dark mode without cookies?
- Clicking .theme-toggle sets data-theme='dark' or 'light' on document.documentElement and saves the string in localStorage under the key 'stf-theme', which never leaves the visitor's browser.
- 25. How does the contact form on /contact/ work without a backend mail server?
- Submitting form[data-mailto] constructs a mailto:contact@sjwebtechwork.com?subject=...&body=... URI in JavaScript and opens the visitor's own email client, requiring zero server endpoints.
Part 4: Parser libraries, edge cases and automated QA testing
- 1. How does client-side search on /search/ query 1,200+ pages instantaneously?
- On load, the search index client fetches the static /search-index.json file once, normalizes size strings like '10 MB' to '10mb', and scores tokens in memory with a 120 ms input debounce.
- 2. Why are custom sizes rounded down when a format has data-step='2' or data-step='512'?
- Formats like 16-bit stereo WAV require 2-byte sample alignment (step=2) and POSIX TAR archives require 512-byte block alignment (step=512); rounding down to the nearest step guarantees a spec-valid file.
- 3. Why are DOCX files capped at 512 MB in the custom size picker?
- Microsoft Word refuses to open .docx files whose internal XML document stream exceeds 512 MB (536,870,912 bytes), so the picker enforces that ceiling up front and recommends ZIP for 1 GB transfer tests.
- 4. How does the Category Bundle ZIP generator on /generator/ build a .zip file in browser memory?
- It encodes each file as a Uint8Array, computes its IEEE 802.3 CRC-32 using a 256-entry lookup table, writes 30-byte Local File Headers (0x04034b50) and 46-byte Central Directory headers (0x02014b50), and appends the 22-byte EOCD record (0x06054b50).
- 5. How does the Inert Stub Generator build safe .exe and .iso test files?
- For .exe, it writes ASCII 'MZ' (0x4D 0x5A) at byte 0 followed by a plain-text non-executable notice at offset 64; for .iso, it writes the ECMA-119 primary volume descriptor '\x01CD001\x01' at sector 16 (offset 32,768) with zero executable code.
- 6. How does the Magic-Byte File Inspector on /inspector/ identify ISO Base Media formats?
- It slices the first 64 KB of the dropped file, checks bytes 4–7 for ASCII 'ftyp' (0x66 0x74 0x79 0x70), and inspects the 4-byte major brand at bytes 8–11 ('avif', 'heic', 'M4A ', 'qt ', 'isom', 'mp42').
- 7. How does the File Inspector differentiate RIFF WAV, RIFF AVI, and RIFF WebP files?
- All three start with 'RIFF' (52 49 46 46) at bytes 0–3 and a 32-bit little-endian length at bytes 4–7, so the inspector reads the 4-character form type at bytes 8–11 ('WAVE', 'AVI ', or 'WEBP').
- 8. Why does SampleTestFiles store direct binary fixtures under /assets/gen/seeds/*.seed?
- Using the uniform .seed extension for static binary fixtures ensures cloud static-asset uploaders never mistake an MPEG-2 Transport Stream (.ts) or source code sample (.py, .php) for an application build script, while the download handler saves the downloaded Blob with its true filename.
- 9. How does the download handler restore the original filename and MIME type when downloading a .seed fixture?
- When you click an a[data-download] link pointing to /assets/gen/seeds/*.seed, the click handler fetches the binary ArrayBuffer, wraps it in a Blob with the link's data-mime attribute, and triggers an anchor download using the link's download attribute.
- 10. Can I still download fixtures using curl or wget if I use their /pub-files/ paths?
- Yes. The root /_redirects file includes permanent 301 redirect rules mapping every /pub-files/... path to its corresponding /assets/gen/seeds/*.seed asset, so curl -fLO follows the 301 automatically.
- 11. How does the Placeholder Image Generator on /tools/ create PNG, JPEG, WebP, and SVG files?
- It draws the requested background color, border frame, diagonal crosshairs, and centered monospace dimension text onto an HTML5 <canvas> element and calls canvas.toBlob() (or serializes an XML <svg> string) locally.
- 12. How does the Image to Base64 tool on /tools/ calculate encoding overhead?
- It compares the original File.size in bytes against the length of the Base64 payload produced by FileReader.readAsDataURL(), showing the exact ~33.3% (4-for-3) character expansion.
- 13. How does the Browser Support Checker on /browser-support/ test audio and video codecs?
- It creates detached <video> and <audio> DOM elements and passes explicit RFC 6381 MIME + codec strings (such as video/mp4; codecs="avc1.42E01E" and audio/ogg; codecs="opus") to canPlayType().
- 14. How does the Stereo Left/Right/Phase test on /test-pages/ isolate audio channels?
- It uses the Web Audio API (AudioContext, two OscillatorNodes at 440 Hz, two GainNodes, and a 2-channel ChannelMergerNode) to route signal strictly to channel 0 (Left), channel 1 (Right), or both channels with inverted polarity (-0.25 gain).
- 15. Why are the A/V Sync and Dead-Pixel tools on /test-pages/ gated behind a checkbox?
- Both tools produce periodic visual flashes or full-screen color transitions; gating them behind an explicit confirmation checkbox protects visitors with photosensitive epilepsy in compliance with WCAG 2.1 Success Criterion 2.3.1.
- 16. How does in-browser file generation reduce server bandwidth and processing load?
- Because the browser synthesizes files locally inside a Web Worker or Service Worker from compact seed data, large downloads do not require server-side file assembly or database queries.
- 17. What security headers are configured in /_headers?
- Every route sends Strict-Transport-Security (max-age=31536000), X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, X-Frame-Options: SAMEORIGIN, Content-Security-Policy: frame-ancestors 'self', and a restrictive Permissions-Policy.
- 18. Why are /assets/* configured with Cache-Control: public, max-age=31536000, immutable?
- All CSS, JS, seed, pack, and template filenames in /assets/ carry a 10-character content hash (such as site.ab8f1430da.css), allowing browsers and CDN edges to cache them for a full year without revalidation.
- 19. Why is /sw.js configured with Cache-Control: no-cache?
- Setting Cache-Control: no-cache on /sw.js ensures browsers always check for a newer Service Worker script on navigation rather than staying stuck on an outdated worker.
- 20. Why are /files.json, /checksums.txt, and /mock-data/* served with Access-Control-Allow-Origin: *?
- Enabling CORS on our JSON manifests and mock REST fixtures allows developers to fetch checksums and test data directly from browser-based code sandboxes, localhost dev servers, and automated test runners.
- 21. Why are the 985 size-combination pages under /sample-files/<ext>/<size>/ marked noindex, follow?
- While size-variant pages are convenient for users who want a dedicated preview and hex dump for a specific size, indexing 985 near-identical pages dilutes search crawl budget and triggers scaled-content filters; keeping them noindex, follow with zero AdSense tags concentrates search authority on our 248 deep reference hubs and guides.
- 22. How does the local file:/// CSS loader fallback in <head> work when previewing an unzipped folder on Windows?
- If you open any index.html file directly from Windows File Explorer via file:///, root-relative /assets/... links do not resolve against C:\; the inline head script detects location.protocol === 'file:' and appends a relative ../assets/site.ab8f1430da.css link automatically.
- 23. How are MD5 audio signatures verified inside generated FLAC files?
- Unlike SHA-256 (which hashes the entire outer .flac file), the 16-byte signature at bytes 26–41 of a FLAC STREAMINFO block is the MD5 hash of the raw unencoded little-endian PCM audio samples; our generator computes both.
- 24. How does Worker chunk folding keep memory low when building a 32 MB file in a Web Worker?
- In the background worker, generated byte chunks are folded into a new Blob([blob, part]) every 64 MB so browsers that spill large Blob segments to disk storage can release the intermediate Uint8Array buffers.
- 25. Where can I inspect the complete list of all 1,229 generated and hosted sample files in JSON format?
- Download or fetch https://www.sampletestfiles.com/files.json, which lists every file's name, format, MIME type, exact byte length, and SHA-256 digest.
Explore more topic-based technical format references
Browse all 20 deep-dive Q&A guides on Testing guides or Frequently asked questions.