@@ -42,11 +42,11 @@ dependencies {
4242```
4343
4444For PackedFormat and EncodedFormat you also need to load the
45- ` kotlinx.serialization ` plugin and core library.
45+ kotlinx.serialization plugin and core library.
4646
4747## Full serialization example
4848
49- Minimal example using the default ` EncodedFormat ` (Base62 + PackedFormat):
49+ Minimal example using the default EncodedFormat (Base62 + PackedFormat):
5050
5151``` kotlin
5252@Serializable
@@ -74,10 +74,8 @@ val decoded = EncodedFormat.decodeFromString<Payload>(encoded)
7474PackedFormat is a BinaryFormat for Kotlin classes that emits compact byte
7575payloads. Booleans and nullability markers share a single bit-header (about one
7676bit per field), and nested objects, lists, maps, and polymorphism are handled
77- recursively. Int and Long fields can be annotated with
78- ` @PackedType(IntPacking.DEFAULT) ` for unsigned varint or
79- ` @PackedType(IntPacking.SIGNED) ` for ZigZag; ` @ProtoType ` is recognized as a
80- fallback.
77+ recursively. Int and Long fields can be annotated with @PackedType to choose
78+ unsigned varint or ZigZag, and @ProtoType is recognized as a fallback.
8179
8280``` kotlin
8381val compactFormat = PackedFormat {
@@ -96,11 +94,11 @@ val bytes = compactFormat.encodeToByteArray(payload)
9694EncodedFormat is a StringFormat that produces short tokens by composing three
9795layers. The binary layer is PackedFormat by default, but ProtoBuf is a good
9896choice when cross-language compatibility matters. After serialization, an
99- optional PayloadTransform can manipulate the bytes — for example ` CompactZeros `
100- to strip leading zeros, ` Checksum.asTransform() ` to append an integrity check,
101- or a custom transform for encryption or error correction; transforms compose
102- with ` PayloadTransform.then ` . Finally a text codec turns the bytes into a
103- string, with Base62 as the default and Base36, Base64, and Base85 available.
97+ optional PayloadTransform can manipulate the bytes, for example CompactZeros to
98+ strip leading zeros, Checksum to append an integrity check, or a custom
99+ transform for encryption or error correction. Transforms compose with
100+ PayloadTransform.then. Finally a text codec turns the bytes into a string, with
101+ Base62 as the default and Base36, Base64, and Base85 available.
104102
105103``` kotlin
106104val customFormat = EncodedFormat {
@@ -140,16 +138,9 @@ Encoding `"any byte data"` (13 bytes):
140138
141139## Extensions
142140
143- There are examples in the jvmTest source of how to extend the encoding with encryption or error correction.
144-
145- ### Encryption
146-
147- Wrap a cipher as a ` PayloadTransform ` and pass it to ` EncodedFormat ` . See
148- [ EncryptionExample] ( https://github.com/Eignex/kencode/blob/main/src/jvmTest/kotlin/com/eignex/kencode/EncryptionExample.kt )
149- for the full example using BouncyCastle.
150-
151- ### Error Correction
152-
153- Wrap an error-correcting code as a ` PayloadTransform ` to recover from corrupted
154- bytes. See [ ErrorCorrectionExample] ( https://github.com/Eignex/kencode/blob/main/src/jvmTest/kotlin/com/eignex/kencode/ErrorCorrectionExample.kt )
155- for the full example using zxing and simulated byte corruption.
141+ EncodedFormat can be extended by wrapping any byte transformation as a
142+ PayloadTransform. The jvmTest source includes two worked examples: an
143+ [ encryption transform] ( https://github.com/Eignex/kencode/blob/main/src/jvmTest/kotlin/com/eignex/kencode/EncryptionExample.kt )
144+ built on BouncyCastle, and an
145+ [ error-correction transform] ( https://github.com/Eignex/kencode/blob/main/src/jvmTest/kotlin/com/eignex/kencode/ErrorCorrectionExample.kt )
146+ built on zxing that recovers from simulated byte corruption.
0 commit comments