Qr Zlib B64
object QrZlibB64
Utilities for QR payloads that are Base64-encoded and deflated (zlib/gzip/raw).
Typical QR issuers compress UTF-8 JSON using zlib/DEFLATE or gzip, then encode with Base64 (often Base64URL without padding). This helper:
decodeBase64ZlibToString:
Base64{URL?} -> inflate{zlib/gzip/raw} -> UTF-8 StringencodeToBase64UrlZlib:
UTF-8 String -> zlib(deflate) -> Base64URL (no padding)
Safety:
Decoding returns null on any failure (bad Base64 / unsupported container / size cap exceeded).
A maxOutputBytes guard prevents inflating to unbounded size (zip-bomb protection).
Thread-safety: this object is stateless; methods are thread-safe.
Since
1.0.0
Functions
Link copied to clipboard
fun encodeToBase64UrlZlib(input: String, level: Int = Deflater.BEST_COMPRESSION, onlyIfSmaller: Boolean = true): String
Compress a UTF-8 string with zlib (DEFLATE + zlib header/Adler32) and encode as Base64URL (no padding).