tuweni / org.apache.tuweni.bytes / Bytes / fromHexStringLenient

fromHexStringLenient

open static fun fromHexStringLenient(str: CharSequence!): Bytes! (source)

Parse a hexadecimal string into a Bytes value.

This method is lenient in that str may of an odd length, in which case it will behave exactly as if it had an additional 0 in front.

Parameters

str - CharSequence!: The hexadecimal string to parse, which may or may not start with "0x".

Exceptions

IllegalArgumentException - if str does not correspond to a valid hexadecimal representation.

Return
Bytes!: The value corresponding to str.

open static fun fromHexStringLenient(str: CharSequence!, destinationSize: Int): Bytes! (source)

Parse a hexadecimal string into a Bytes value of the provided size.

This method allows for str to have an odd length, in which case it will behave exactly as if it had an additional 0 in front.

Parameters

str - CharSequence!: The hexadecimal string to parse, which may or may not start with "0x".

destinationSize - Int: The size of the returned value, which must be big enough to hold the bytes represented by str. If it is strictly bigger those bytes from str, the returned value will be left padded with zeros.

Exceptions

IllegalArgumentException - if str does not correspond to a valid hexadecimal representation, represents more bytes than destinationSize or destinationSize < 0.

Return
Bytes!: A value of size destinationSize corresponding to str potentially left-padded.