BitConverter.bytesMethod
bytes(x::Integer; len::Integer, little_endian::Bool)
-> Vector{len, UInt8}

Convert an Integer x to a Vector{UInt8} Options (not available for x::BigInt):

  • len to define a minimum Vector lenght in bytes, result will show no leading

zero by default.

  • set little_endian to true for a result in little endian byte order, result

in big endian order by default.

julia> bytes(32974)
2-element Array{UInt8,1}:
 0x80
 0xce

julia> bytes(32974, len=4)
4-element Array{UInt8,1}:
 0x00
 0x00
 0x80
 0xce

julia> bytes(32974, little_endian=true)
2-element Array{UInt8,1}:
 0xce
 0x80
BitConverter.to_bigMethod
to_big(x::Vector{UInt8}) -> BigInt

Convert a Vector{UInt8} of any lenght to a BigInt. Considers the input a big endian.

julia> to_big([0x01, 0x00])
256
BitConverter.to_intMethod
Int(x::Vector{UInt8}; little_endian::Bool)
-> Integer

Convert a Vector{UInt8} an Integer, a BigInt above 64 bits Optionally set little_endian to true if the input as such byte order, input is considered big endian by default.

julia> Int([0x01, 0x00])
256

julia> Int([0x01, 0x00], little_endian=true)
1