module Rlp::Util
Overview
Exposes a set of utilities to ease the handling of different data types.
Defined in:
util.crClass Method Summary
-
.bin_to_hex(b : Bytes)
Converts binary bytes to a hex-encoded string.
-
.bin_to_int(b : Bytes)
Converts binary bytes to a big integer.
-
.bin_to_str(b : Bytes)
Converts binary bytes to a string literal.
-
.binary_add(a : Bytes, b : Bytes)
concatenates two byte slices of uint8
-
.hex_to_bin(h : String)
Converts hex-encoded strings to binary bytes data.
-
.hex_to_int(h : String)
Converts hex-encoded strings to big integers.
-
.hex_to_str(h : String)
Converts hex-encoded strings to string literals.
-
.int_to_bin(i : Int)
Converts big integers to binary bytes.
-
.int_to_hex(i : Int)
Converts big integers to hex-encoded strings.
-
.str_to_bin(s : String)
Converts string literals to binary bytes data.
-
.str_to_hex(s : String)
Converts string literals to hex-encoded strings.
Class Method Detail
Converts binary bytes to a hex-encoded string.
Parameters:
b
(Bytes
): the binary bytes data to convert.
Rlp::Util.bin_to_hex Bytes[4, 200, 29])
# => "04c81d"
Converts binary bytes to a big integer.
Parameters:
b
(Bytes
): the binary bytes data to convert.
Rlp::Util.bin_to_int Bytes[15, 66, 64])
# => 1000000
Converts binary bytes to a string literal.
Parameters:
b
(Bytes
): the binary bytes data to convert.
Rlp::Util.bin_to_str Bytes[97, 98, 99])
# => "abc"
Converts hex-encoded strings to binary bytes data.
Parameters:
h
(String
): the hex-encoded string to convert.
Rlp::Util.hex_to_bin "04c81d"
# => Bytes[4, 200, 29]
Converts hex-encoded strings to big integers.
Parameters:
h
(String
): the hex-encoded string to convert.
Rlp::Util.hex_to_int "04c81d"
# => 313373
Converts hex-encoded strings to string literals.
Parameters:
h
(String
): the hex-encoded string to convert.
Rlp::Util.hex_to_str "646f67"
# => "dog"
Converts big integers to binary bytes.
Parameters:
i
(Int
): the big integer to convert.
Rlp::Util.int_to_bin 1_000_000
# => Bytes[15, 66, 64]
Converts big integers to hex-encoded strings.
Parameters:
i
(Int
): the big integer to convert.
Rlp::Util.int_to_hex 313_373
# => "04c81d"
Converts string literals to binary bytes data.
Parameters:
s
(String
): the string literal to convert.
Rlp::Util.str_to_bin "abc"
# => Bytes[97, 98, 99]
Converts string literals to hex-encoded strings.
Parameters:
s
(String
): the string literal to convert.
Rlp::Util.str_to_hex "dog"
# => "646f67"