encodeIntoByteArray

fun encodeIntoByteArray(source: ByteArray, destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = source.size): Int(source)

Encodes bytes from the specified source array or its subrange and writes resulting symbols into the destination array. Returns the number of symbols written.

If the size of the source array or its subrange is not an integral multiple of 3, the result is padded with '=' to an integral multiple of 4 symbols.

Since Kotlin

1.8

Return

the number of symbols written into destination array.

Parameters

source

the array to encode bytes from.

destination

the array to write symbols into.

destinationOffset

the starting index in the destination array to write symbols to, 0 by default.

startIndex

the beginning (inclusive) of the subrange to encode, 0 by default.

endIndex

the end (exclusive) of the subrange to encode, size of the source array by default.

Throws

when the resulting symbols don't fit into the destination array starting at the specified destinationOffset, or when that index is out of the destination array indices range.

when startIndex > endIndex.