Skip to content

Commit 7a94883

Browse files
committed
docs: drop code examples from Extensions section
1 parent f303247 commit 7a94883

1 file changed

Lines changed: 4 additions & 37 deletions

File tree

README.md

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -144,45 +144,12 @@ There are examples in the jvmTest source of how to extend the encoding with encr
144144

145145
### Encryption
146146

147-
Wrap a cipher as a `PayloadTransform` and pass it to `EncodedFormat`:
148-
149-
```kotlin
150-
@Serializable
151-
data class SecretPayload(val id: Long)
152-
153-
val encryptingTransform = object : PayloadTransform {
154-
override fun encode(data: ByteArray): ByteArray = cipher.encrypt(data)
155-
override fun decode(data: ByteArray): ByteArray = cipher.decrypt(data)
156-
}
157-
158-
val secureFormat = EncodedFormat {
159-
transform = encryptingTransform
160-
}
161-
162-
val token = secureFormat.encodeToString(SecretPayload.serializer(), payload)
163-
val decoded = secureFormat.decodeFromString(SecretPayload.serializer(), token)
164-
```
165-
166-
See [EncryptionExample](https://github.com/Eignex/kencode/blob/main/src/jvmTest/kotlin/com/eignex/kencode/EncryptionExample.kt)
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)
167149
for the full example using BouncyCastle.
168150

169151
### Error Correction
170152

171-
Wrap an error-correcting code as a `PayloadTransform` to recover from corrupted bytes:
172-
173-
```kotlin
174-
val eccTransform = object : PayloadTransform {
175-
override fun encode(data: ByteArray): ByteArray = ecc.encode(data)
176-
override fun decode(data: ByteArray): ByteArray = ecc.decode(data)
177-
}
178-
179-
val robustFormat = EncodedFormat {
180-
transform = eccTransform
181-
}
182-
183-
val token = robustFormat.encodeToString(SecretPayload.serializer(), payload)
184-
val decoded = robustFormat.decodeFromString(SecretPayload.serializer(), token)
185-
```
186-
187-
See [ErrorCorrectionExample](https://github.com/Eignex/kencode/blob/main/src/jvmTest/kotlin/com/eignex/kencode/ErrorCorrectionExample.kt)
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)
188155
for the full example using zxing and simulated byte corruption.

0 commit comments

Comments
 (0)