library / org.akop.kotx.tools.basic / buildByteArray

buildByteArray

fun buildByteArray(block: ByteArrayBuilder.() -> Unit): ByteArray

Creates a new ByteArrayBuilder instance, calls block with the builder as receiver, finally returning the ByteArray generated by call to ByteArrayBuilder.build.

Example:

val encryptedString = buildByteArray {
    append("Salted__".toByteArray())
    append(salt)
    append(cipher.doFinal(message.toByteArray()))
}.toBase64String()