Hex
scalus.utils.Hex
object Hex
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Hex.type
Members list
Value members
Concrete methods
Extensions
Extensions
extension (bytes: Array[Byte])
Converts an array of bytes to a hex string.
Converts an array of bytes to a hex string.
Example:
val bytes = Array[Byte](0x0f, 0xa0.toByte, 0x5c)
val hexString = bytes.toHex // "0fa05c"
Value parameters
- bytes
-
the array of bytes to convert
Attributes
- Returns
-
the hex string representation of the byte array
extension (hex: String)
Converts a hex string to an array of bytes.
Converts a hex string to an array of bytes.
The hex string may contain whitespace characters, which will be ignored. Case insensitive.
Example:
val bytes = "0fa05c".hexToBytes // Array[Byte](0x0f, 0xa0.toByte, 0x5c)
Value parameters
- hex
-
the hex string to convert
Attributes
- Returns
-
the array of bytes represented by the hex string
- Throws
-
IllegalArgumentException
if the string is not a valid hex string (not even length or contains non-hex characters)
In this article