View Source BitcoinLib.Crypto.Bitstring (BitcoinLib v0.4.7)

Bitstring manipulation functions

Link to this section Summary

Functions

Takes any bistring and returns bytes in the reverse order, such as going from little endian to big endian or the opposite

Link to this section Functions

@spec reverse(bitstring()) :: bitstring()

Takes any bistring and returns bytes in the reverse order, such as going from little endian to big endian or the opposite

possible-improvement

Possible improvement

Found out that this code would also work, might have to test for performance

  <<0xb62e9d36389427d39e5d438a05045c23d1938e4242661c5fe2ad87c46337b091::256>>
  |> :binary.decode_unsigned(:big) # could omit :big since it's default
  |> :binary.encode_unsigned(:little)
  <<0x91b03763c487ade25f1c6642428e93d1235c04058a435d9ed3279438369d2eb6::256>>

examples

Examples

iex> <<0xb62e9d36389427d39e5d438a05045c23d1938e4242661c5fe2ad87c46337b091::256>>
...> |> BitcoinLib.Crypto.Bitstring.reverse()
<<0x91b03763c487ade25f1c6642428e93d1235c04058a435d9ed3279438369d2eb6::256>>