com.github.rs3vans.krypto / Bytes

Bytes

class Bytes : Any

A class that wraps a ByteArray, providing ease-of-use and additional functionality.

Constructors

<init> Bytes(byteArray: ByteArray)

A class that wraps a ByteArray, providing ease-of-use and additional functionality.

Properties

byteArray val byteArray: ByteArray
size val size: Int

Functions

copy fun copy(): Bytes

Creates a deep copy of this Bytes, where the new instance's byteArray is an entirely new ByteArray with each byte copied by value.

copyOfRange fun copyOfRange(range: IntRange): Bytes

Creates a deep copy of this Bytes, where the new instance's byteArray is an entirely new ByteArray with each byte within range copied by value.

deserializeToObject fun <T : Serializable> deserializeToObject(): T

Convert a Bytes into a T by deserializing it using an ObjectInputStream.

equals fun equals(other: Any?): Boolean
hashCode fun hashCode(): Int
plus operator fun plus(other: Bytes): Bytes

Create a new Bytes that is byteArray with other.byteArray appended directly after.

toBase64String fun toBase64String(): String

Convert a Bytes into a Base64-encoded String.

toByteBuffer fun toByteBuffer(): ByteBuffer

Convert a Bytes into a ByteBuffer.

toDecodedString fun toDecodedString(charset: Charset = Charsets.UTF_8): String

Convert a Bytes into a String by decoding it using the given Charset, assuming it contains character data.

toHexString fun toHexString(): String

Convert a Bytes into a Hex-encoded String.

toInputStream fun toInputStream(): InputStream

Convert a Bytes into an InputStream.

toString fun toString(): String

Companion Object Properties

DEFAULT_RANDOM_BYTES_SIZE const val DEFAULT_RANDOM_BYTES_SIZE: Int

Companion Object Functions

generateRandomBytes fun generateRandomBytes(size: Int = DEFAULT_RANDOM_BYTES_SIZE): Bytes

Generate random Bytes of a given size.