ByteString

actual open class ByteString : Comparable<ByteString>
expect open class ByteString : Comparable<ByteString>

An immutable sequence of bytes.

Byte strings compare lexicographically as a sequence of unsigned bytes. That is, the byte string ff sorts after 00. This is counter to the sort order of the corresponding bytes, where -1 sorts before 0.

Full disclosure: this class provides untrusted input and output streams with raw access to the underlying byte array. A hostile stream implementation could keep a reference to the mutable byte string, violating the immutable guarantee of this class. For this reason a byte string's immutability guarantee cannot be relied upon for security in applets and other environments that run both trusted and untrusted code in the same process.

actual open class ByteString : Comparable<ByteString>

Types

Link copied to clipboard
actual object Companion
expect object Companion
actual object Companion
actual object Companion

Properties

Link copied to clipboard
actual val size: Int
@get:JvmName(name = "size")
expect val size: Int

Returns the number of bytes in this ByteString.

@get:JvmName(name = "size")
actual val size: Int
actual val size: Int

Functions

Link copied to clipboard

Returns a ByteBuffer view of the bytes in this ByteString.

Link copied to clipboard
actual open fun base64(): String
expect fun base64(): String

Returns this byte string encoded as Base64. In violation of the RFC, the returned string does not wrap lines at 76 columns.

actual open fun base64(): String
actual open fun base64(): String
Link copied to clipboard
actual open fun base64Url(): String
expect fun base64Url(): String

Returns this byte string encoded as URL-safe Base64.

actual open fun base64Url(): String
actual open fun base64Url(): String
Link copied to clipboard
actual open operator override fun compareTo(other: ByteString): Int
expect open operator override fun compareTo(other: ByteString): Int
actual open operator override fun compareTo(other: ByteString): Int
actual open operator override fun compareTo(other: ByteString): Int
Link copied to clipboard
actual open fun copyInto(offset: Int, target: ByteArray, targetOffset: Int, byteCount: Int)
expect fun copyInto(offset: Int = 0, target: ByteArray, targetOffset: Int = 0, byteCount: Int)

Copies bytes of this in [offset..offset+byteCount] to other in [targetOffset..targetOffset+byteCount].

actual open fun copyInto(offset: Int, target: ByteArray, targetOffset: Int, byteCount: Int)
actual open fun copyInto(offset: Int, target: ByteArray, targetOffset: Int, byteCount: Int)
Link copied to clipboard
actual fun endsWith(suffix: ByteArray): Boolean
actual fun endsWith(suffix: ByteString): Boolean
expect fun endsWith(suffix: ByteArray): Boolean
expect fun endsWith(suffix: ByteString): Boolean
actual fun endsWith(suffix: ByteArray): Boolean
actual fun endsWith(suffix: ByteString): Boolean
actual fun endsWith(suffix: ByteArray): Boolean
actual fun endsWith(suffix: ByteString): Boolean
Link copied to clipboard
actual open operator override fun equals(other: Any?): Boolean
expect open operator override fun equals(other: Any?): Boolean
actual open operator override fun equals(other: Any?): Boolean
actual open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
actual operator fun get(index: Int): Byte
@JvmName(name = "getByte")
expect operator fun get(index: Int): Byte

Returns the byte at index.

@JvmName(name = "getByte")
actual operator fun get(index: Int): Byte
actual operator fun get(index: Int): Byte
Link copied to clipboard
actual open override fun hashCode(): Int
expect open override fun hashCode(): Int
actual open override fun hashCode(): Int
actual open override fun hashCode(): Int
Link copied to clipboard
actual open fun hex(): String
expect fun hex(): String

Returns this byte string encoded in hexadecimal.

actual open fun hex(): String
actual open fun hex(): String
Link copied to clipboard
actual fun hmacSha1(key: ByteString): ByteString

Returns the 160-bit SHA-1 HMAC of this byte string.

expect fun hmacSha1(key: ByteString): ByteString

Returns the 160-bit SHA-1 HMAC of this byte string.

actual open fun hmacSha1(key: ByteString): ByteString

Returns the 160-bit SHA-1 HMAC of this byte string.

actual fun hmacSha1(key: ByteString): ByteString

Returns the 160-bit SHA-1 HMAC of this byte string.

Link copied to clipboard
actual fun hmacSha256(key: ByteString): ByteString

Returns the 256-bit SHA-256 HMAC of this byte string.

expect fun hmacSha256(key: ByteString): ByteString

Returns the 256-bit SHA-256 HMAC of this byte string.

actual open fun hmacSha256(key: ByteString): ByteString

Returns the 256-bit SHA-256 HMAC of this byte string.

actual fun hmacSha256(key: ByteString): ByteString

Returns the 256-bit SHA-256 HMAC of this byte string.

Link copied to clipboard
actual fun hmacSha512(key: ByteString): ByteString

Returns the 512-bit SHA-512 HMAC of this byte string.

expect fun hmacSha512(key: ByteString): ByteString

Returns the 512-bit SHA-512 HMAC of this byte string.

actual open fun hmacSha512(key: ByteString): ByteString

Returns the 512-bit SHA-512 HMAC of this byte string.

actual fun hmacSha512(key: ByteString): ByteString

Returns the 512-bit SHA-512 HMAC of this byte string.

Link copied to clipboard
actual open fun indexOf(other: ByteArray, fromIndex: Int): Int
actual fun indexOf(other: ByteString, fromIndex: Int): Int
expect fun indexOf(other: ByteArray, fromIndex: Int = 0): Int
expect fun indexOf(other: ByteString, fromIndex: Int = 0): Int
actual open fun indexOf(other: ByteArray, fromIndex: Int): Int
actual fun indexOf(other: ByteString, fromIndex: Int): Int
actual open fun indexOf(other: ByteArray, fromIndex: Int): Int
actual fun indexOf(other: ByteString, fromIndex: Int): Int
Link copied to clipboard
actual open fun lastIndexOf(other: ByteArray, fromIndex: Int): Int
actual fun lastIndexOf(other: ByteString, fromIndex: Int): Int
expect fun lastIndexOf(other: ByteArray, fromIndex: Int = DEFAULT__ByteString_size): Int
expect fun lastIndexOf(other: ByteString, fromIndex: Int = DEFAULT__ByteString_size): Int
actual open fun lastIndexOf(other: ByteArray, fromIndex: Int): Int
actual fun lastIndexOf(other: ByteString, fromIndex: Int): Int
actual open fun lastIndexOf(other: ByteArray, fromIndex: Int): Int
actual fun lastIndexOf(other: ByteString, fromIndex: Int): Int
Link copied to clipboard
actual fun md5(): ByteString
expect fun md5(): ByteString

Returns the 128-bit MD5 hash of this byte string.

actual fun md5(): ByteString
actual fun md5(): ByteString
Link copied to clipboard
actual open fun rangeEquals(offset: Int, other: ByteArray, otherOffset: Int, byteCount: Int): Boolean
actual open fun rangeEquals(offset: Int, other: ByteString, otherOffset: Int, byteCount: Int): Boolean
expect fun rangeEquals(offset: Int, other: ByteArray, otherOffset: Int, byteCount: Int): Boolean
expect fun rangeEquals(offset: Int, other: ByteString, otherOffset: Int, byteCount: Int): Boolean

Returns true if the bytes of this in [offset..offset+byteCount) equal the bytes of other in [otherOffset..otherOffset+byteCount). Returns false if either range is out of bounds.

actual open fun rangeEquals(offset: Int, other: ByteArray, otherOffset: Int, byteCount: Int): Boolean
actual open fun rangeEquals(offset: Int, other: ByteString, otherOffset: Int, byteCount: Int): Boolean
actual open fun rangeEquals(offset: Int, other: ByteArray, otherOffset: Int, byteCount: Int): Boolean
actual open fun rangeEquals(offset: Int, other: ByteString, otherOffset: Int, byteCount: Int): Boolean
Link copied to clipboard
actual fun sha1(): ByteString
expect fun sha1(): ByteString

Returns the 160-bit SHA-1 hash of this byte string.

actual fun sha1(): ByteString
actual fun sha1(): ByteString
Link copied to clipboard
actual fun sha256(): ByteString
expect fun sha256(): ByteString

Returns the 256-bit SHA-256 hash of this byte string.

actual fun sha256(): ByteString
actual fun sha256(): ByteString
Link copied to clipboard
actual fun sha512(): ByteString
expect fun sha512(): ByteString

Returns the 512-bit SHA-512 hash of this byte string.

actual fun sha512(): ByteString
actual fun sha512(): ByteString
Link copied to clipboard
actual fun startsWith(prefix: ByteArray): Boolean
actual fun startsWith(prefix: ByteString): Boolean
expect fun startsWith(prefix: ByteArray): Boolean
expect fun startsWith(prefix: ByteString): Boolean
actual fun startsWith(prefix: ByteArray): Boolean
actual fun startsWith(prefix: ByteString): Boolean
actual fun startsWith(prefix: ByteArray): Boolean
actual fun startsWith(prefix: ByteString): Boolean
Link copied to clipboard
open fun string(charset: Charset): String

Constructs a new String by decoding the bytes using charset.

Link copied to clipboard
actual open fun substring(beginIndex: Int, endIndex: Int): ByteString
expect fun substring(beginIndex: Int = 0, endIndex: Int = DEFAULT__ByteString_size): ByteString

Returns a byte string that is a substring of this byte string, beginning at the specified beginIndex and ends at the specified endIndex. Returns this byte string if beginIndex is 0 and endIndex is the length of this byte string.

actual open fun substring(beginIndex: Int, endIndex: Int): ByteString
actual open fun substring(beginIndex: Int, endIndex: Int): ByteString
Link copied to clipboard
actual open fun toAsciiLowercase(): ByteString

Returns a byte string equal to this byte string, but with the bytes 'A' through 'Z' replaced with the corresponding byte in 'a' through 'z'. Returns this byte string if it contains no bytes in 'A' through 'Z'.

actual open fun toAsciiLowercase(): ByteString
actual open fun toAsciiLowercase(): ByteString
Link copied to clipboard
actual open fun toAsciiUppercase(): ByteString

Returns a byte string equal to this byte string, but with the bytes 'a' through 'z' replaced with the corresponding byte in 'A' through 'Z'. Returns this byte string if it contains no bytes in 'a' through 'z'.

actual open fun toAsciiUppercase(): ByteString
actual open fun toAsciiUppercase(): ByteString
Link copied to clipboard
actual open fun toByteArray(): ByteArray
expect fun toByteArray(): ByteArray

Returns a byte array containing a copy of the bytes in this ByteString.

actual open fun toByteArray(): ByteArray
actual open fun toByteArray(): ByteArray
Link copied to clipboard
actual open override fun toString(): String

Returns a human-readable string that describes the contents of this byte string. Typically this is a string like [text=Hello] or [hex=0000ffff].

expect open override fun toString(): String

Returns a human-readable string that describes the contents of this byte string. Typically this is a string like [text=Hello] or [hex=0000ffff].

actual open override fun toString(): String
actual open override fun toString(): String

Returns a human-readable string that describes the contents of this byte string. Typically this is a string like [text=Hello] or [hex=0000ffff].

Link copied to clipboard
actual open fun utf8(): String
expect fun utf8(): String

Constructs a new String by decoding the bytes as UTF-8.

actual open fun utf8(): String
actual open fun utf8(): String
Link copied to clipboard
open fun write(out: OutputStream)

Writes the contents of this byte string to out.