BytesRepresentationConverter
internal final class BytesRepresentationConverter
Utility class for converting between binary and hexadecimal representations.
-
Convert a hexadecimal number to a binary representation.
Declaration
Swift
internal static func convertToBinaryRepresentation(from hex: HexadecimalNumber, withAtLeastHexDigits hexDigits: Int = 2) -> BinaryRepresentation
Parameters
hex
The hexadecimal number (
UInt64
) to convert.hexDigits
The minimum number of hexadecimal digits to consider (default is 2).
Return Value
A binary representation (
[UInt8]
). -
Convert a hexadecimal representation to a binary representation.
Declaration
Swift
internal static func convertToBinaryRepresentation(from hex: HexRepresentation) -> BinaryRepresentation
Parameters
hex
The hexadecimal representation (
String
) to convert.Return Value
A binary representation (
[UInt8]
).
-
Convert a byte to a hexadecimal representation.
Declaration
Swift
internal static func convertToHexRepresentation(from byte: Byte) -> HexRepresentation
Parameters
byte
The byte (
UInt8
) to convert.Return Value
A hexadecimal representation (
String
). -
Convert a slice of bytes to a hexadecimal representation.
Declaration
Swift
internal static func convertToHexRepresentation(from bytes: ArraySlice<Byte>) -> HexRepresentation
Parameters
bytes
The slice of bytes (
ArraySlice<UInt8>
) to convert.Return Value
A hexadecimal representation (
String
). -
Convert a sequence of bytes to a hexadecimal representation.
Declaration
Swift
internal static func convertToHexRepresentation(from bytes: BinaryRepresentation) -> HexRepresentation
Parameters
bytes
The sequence of bytes (
[UInt8]
) to convert.Return Value
A hexadecimal representation (
String
). -
Convert a hexadecimal number to a hexadecimal representation.
Declaration
Swift
internal static func converToHexRepresentation(from hex: HexadecimalNumber) -> HexRepresentation
Parameters
hex
The hexadecimal number (
UInt64
) to convert.Return Value
A hexadecimal representation (
String
).
-
Convert a byte to a hexadecimal number.
Declaration
Swift
internal static func convertToHexNumber(from byte: Byte) -> HexadecimalNumber
Parameters
byte
The byte (
UInt8
) to convert.Return Value
A hexadecimal number (
UInt64
). -
Convert a slice of bytes to a hexadecimal number.
Declaration
Swift
internal static func convertToHexNumber(from bytes: ArraySlice<Byte>) -> HexadecimalNumber
Parameters
bytes
The slice of bytes (
ArraySlice<UInt8>
) to convert.Return Value
A hexadecimal number (
UInt64
). -
Convert a sequence of bytes to a hexadecimal number.
Declaration
Swift
internal static func convertToHexNumber(from bytes: BinaryRepresentation) -> HexadecimalNumber
Parameters
bytes
The sequence of bytes (
[UInt8]
) to convert.Return Value
A hexadecimal number (
UInt64
).