ByteArray
Represents an array of bytes (i.e. an array of uint8 numbers).
byte_array = #213212; ...
Note: in Haskell/Plutus this is called a
ByteString
, but we thought that that was too ambiguous, so we choseByteArray
instead.
Associated functions
from_data
ByteArray::from_data(data: Data) -> ByteArray
parse
Parses a hexadecimal encoded ByteArray
.
ByteArray::parse(hex: String) -> String
Getters
length
Returns the number of bytes in the ByteArray
.
byte_array.length -> Int
Operators
==
ByteArray == ByteArray -> Bool
!=
ByteArray != ByteArray -> Bool
>=
ByteArray >= ByteArray -> Bool
>
The lhs is greater-than the rhs if the first rhs byte, that isn't equal to the corresponding lhs byte, is smaller than that byte. Returns true if all common bytes are equal, but the rhs is shorter than the lhs.
ByteArray > ByteArray -> Bool
<=
ByteArray <= ByteArray -> Bool
<
The lhs is less-than the rhs if the first rhs byte, that isn't equal to the corresponding lhs byte, is greater than that byte. Returns false if the rhs is empty.
ByteArray < ByteArray -> Bool
+
Concatenation of two ByteArray
s.
ByteArray + ByteArray -> ByteArray
Methods
blake2b
Calculates the blake2b-256 hash of a ByteArray
. The result is 32 bytes long.
byte_array.blake2b() -> ByteArray
decode_utf8
Turns a valid sequence of utf-8 bytes into a String
. Throws an error if the ByteArray
isn't valid utf-8.
byte_array.decode_utf8() -> String
ends_with
Checks if a ByteArray
ends with a given suffix.
byte_array.ends_with(suffix: ByteArray) -> Bool
prepend
Prepends an Int
byte, returning a new ByteArray
.
Modulo 256 is applied internally to the byte before prepending.
byte_array.prepend(byte: Int) -> ByteArray
serialize
byte_array.serialize() -> ByteArray
sha2
Calculates the sha2-256 hash of a ByteArray
. The result is 32 bytes long.
byte_array.sha2() -> ByteArray
sha3
Calculates the sha3-256 hash of a ByteArray
. The result is 32 bytes long.
byte_array.sha3() -> ByteArray
show
Converts a ByteArray
into its hexadecimal representation.
byte_array.show() -> String
slice
byte_array.slice(start: Int, end: Int) -> ByteArray
starts_with
Checks if a ByteArray
starts with a given prefix.
byte_array.starts_with(prefix: ByteArray) -> Bool