Skip to content

missing bswap function #26

@stevengj

Description

@stevengj

It would be nice to be able to convert bigendian data, e.g. SHA hashes as in this discourse thread to UInt256 etcetera, but this currently fails because bswap is not implemented:

julia> h = rand(UInt8, 32);

julia> bytes2hex(h) # interprets h as bigendian
"b9a868cba886baa10e08c841e8c0eabac34b83de68207c8bad6f2c869bc4a547"

julia> reinterpret(UInt256, h) # uses a different byte order
1-element reinterpret(UInt256, ::Vector{UInt8}):
 0x47a5c49b862c6fad8b7c2068de834bc3baeac0e841c8080ea1ba86a8cb68a8b9

julia> ntoh(reinterpret(UInt256, h)) # should convert bigendian to host native order
ERROR: MethodError: no method matching bswap(::Base.ReinterpretArray{UInt256, 1, UInt8, Vector{UInt8}, false})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions