@@ -90,7 +90,7 @@ val compactFormat = PackedFormat {
9090 defaultEncoding = PackedIntegerType .SIGNED
9191 serializersModule = myCustomModule
9292}
93- val bytes = PackedFormat .encodeToBytes (payload)
93+ val bytes = compactFormat.encodeToByteArray (payload)
9494```
9595
9696---
@@ -102,9 +102,10 @@ composing three layers:
102102
1031031 . Binary Layer: PackedFormat (default) or ProtoBuf (recommended for
104104 cross-language compatibility).
105- 2 . Transform Layer: Optional ` PayloadTransform ` applied after serialization —
106- use ` Checksum.asTransform() ` for integrity checks, or supply your own for
107- encryption or error-correcting codes.
105+ 2 . Transform Layer: Optional ` PayloadTransform ` applied after serialization.
106+ Use ` CompactZeros ` to strip leading zero bytes, ` Checksum.asTransform() ` for
107+ integrity checks, or supply your own for encryption or error-correcting codes.
108+ Chain multiple transforms with ` PayloadTransform.then ` .
1081093 . Text Layer: Base62 (default), Base36, Base64, or Base85.
109110
110111``` kotlin
@@ -115,6 +116,11 @@ val customFormat = EncodedFormat {
115116}
116117
117118val token = customFormat.encodeToString(payload)
119+
120+ // Chain transforms: strip leading zeros, then append checksum
121+ val withBoth = EncodedFormat {
122+ transform = CompactZeros .then(Crc16 .asTransform())
123+ }
118124```
119125
120126---
@@ -153,5 +159,5 @@ val token = secureFormat.encodeToString(SecretPayload.serializer(), payload)
153159val decoded = secureFormat.decodeFromString(SecretPayload .serializer(), token)
154160```
155161
156- See [ Examples] ( https://github.com/Eignex/kencode/blob/main/src/test /kotlin/com/eignex/kencode/Examples.kt )
162+ See [ Examples] ( https://github.com/Eignex/kencode/blob/main/src/jvmTest /kotlin/com/eignex/kencode/Examples.kt )
157163for a BouncyCastle demo.
0 commit comments