resx_base v0.1.0 ResxBase

Link to this section Summary

Functions

Decodes encoded strings produced by the encode16_lower/3 function.

Decodes encoded strings produced by the encode16_upper/3 function.

Decodes encoded strings produced by the encode32/3 function.

Decodes encoded strings produced by the encode64/3 function.

Encodes data into a string which can be decoded using the decode16_lower/3 function.

Encodes data into a string which can be decoded using the decode16_upper/3 function.

Encodes data into a string which can be decoded using the decode32/3 function.

Encodes data into a string which can be decoded using the decode64/3 function.

Decodes encoded strings produced by the hex_encode32/3 function.

Encodes data into a string which can be decoded using the hex_decode32/3 function.

Decodes encoded strings produced by the url_encode64/3 function.

Encodes data into a string which can be decoded using the url_decode64/3 function.

Link to this section Functions

Link to this function

decode16_lower(encoding, opts \\ [], data \\ <<>>)
decode16_lower(bitstring(), Itsy.Binary.decode_options(), bitstring()) ::
  {:ok, bitstring()} | :error

Decodes encoded strings produced by the encode16_lower/3 function.

By default the decoded data will be stripped of any bits that do not fit in the byte boundaries. This behaviour can be changed by setting the :bits option to true. The resulting bitstring may contain some pad bits.

If the encoded string contains some padding characters these will to be specified so they can be removed. Set the :pad_chr option to the padding sequence that was used when encoding this data. Multiple encoded strings with the same padding sequence can be chained together, and will be decoded into a contiguous set of data.

iex> ResxBase.decode16_lower("0")
{ :ok, "" }

iex> ResxBase.decode16_lower("0", bits: true)
{ :ok, <<0::size(4)>> }

iex> ResxBase.decode16_lower("0\a", bits: true, pad_chr: "\a")
{ :ok, <<0::size(4)>> }

iex> ResxBase.decode16_lower("0000", bits: true)
{ :ok, <<0, 0>> }
Link to this function

decode16_upper(encoding, opts \\ [], data \\ <<>>)
decode16_upper(bitstring(), Itsy.Binary.decode_options(), bitstring()) ::
  {:ok, bitstring()} | :error

Decodes encoded strings produced by the encode16_upper/3 function.

By default the decoded data will be stripped of any bits that do not fit in the byte boundaries. This behaviour can be changed by setting the :bits option to true. The resulting bitstring may contain some pad bits.

If the encoded string contains some padding characters these will to be specified so they can be removed. Set the :pad_chr option to the padding sequence that was used when encoding this data. Multiple encoded strings with the same padding sequence can be chained together, and will be decoded into a contiguous set of data.

iex> ResxBase.decode16_upper("0")
{ :ok, "" }

iex> ResxBase.decode16_upper("0", bits: true)
{ :ok, <<0::size(4)>> }

iex> ResxBase.decode16_upper("0\a", bits: true, pad_chr: "\a")
{ :ok, <<0::size(4)>> }

iex> ResxBase.decode16_upper("0000", bits: true)
{ :ok, <<0, 0>> }
Link to this function

decode32(encoding, opts \\ [], data \\ <<>>)
decode32(bitstring(), Itsy.Binary.decode_options(), bitstring()) ::
  {:ok, bitstring()} | :error

Decodes encoded strings produced by the encode32/3 function.

By default the decoded data will be stripped of any bits that do not fit in the byte boundaries. This behaviour can be changed by setting the :bits option to true. The resulting bitstring may contain some pad bits.

If the encoded string contains some padding characters these will to be specified so they can be removed. Set the :pad_chr option to the padding sequence that was used when encoding this data. Multiple encoded strings with the same padding sequence can be chained together, and will be decoded into a contiguous set of data.

iex> ResxBase.decode32("A")
{ :ok, "" }

iex> ResxBase.decode32("A", bits: true)
{ :ok, <<0::size(5)>> }

iex> ResxBase.decode32("A\a\a\a\a\a\a\a", bits: true, pad_chr: "\a")
{ :ok, <<0::size(5)>> }

iex> ResxBase.decode32("AAAA", bits: true)
{ :ok, <<0, 0, 0::size(4)>> }
Link to this function

decode64(encoding, opts \\ [], data \\ <<>>)
decode64(bitstring(), Itsy.Binary.decode_options(), bitstring()) ::
  {:ok, bitstring()} | :error

Decodes encoded strings produced by the encode64/3 function.

By default the decoded data will be stripped of any bits that do not fit in the byte boundaries. This behaviour can be changed by setting the :bits option to true. The resulting bitstring may contain some pad bits.

If the encoded string contains some padding characters these will to be specified so they can be removed. Set the :pad_chr option to the padding sequence that was used when encoding this data. Multiple encoded strings with the same padding sequence can be chained together, and will be decoded into a contiguous set of data.

iex> ResxBase.decode64("A")
{ :ok, "" }

iex> ResxBase.decode64("A", bits: true)
{ :ok, <<0::size(6)>> }

iex> ResxBase.decode64("A\a\a\a", bits: true, pad_chr: "\a")
{ :ok, <<0::size(6)>> }

iex> ResxBase.decode64("AAAA", bits: true)
{ :ok, <<0, 0, 0>> }
Link to this function

encode16_lower(data, opts \\ [], encoding \\ "")
encode16_lower(bitstring(), Itsy.Binary.encode_options(), binary()) :: binary()

Encodes data into a string which can be decoded using the decode16_lower/3 function.

The encoded data will pad any bits needed to make the entire data fit within byte boundaries. By default this padding will be using 0 bits, however this can be changed by setting the option :pad_bit to the specific bit sequence desired (note that only the part of the bit sequence needed to reach a byte boundary will be used).

Optionally an encoded string can have additional padding put onto the final encoding (e.g. if you wanted to pack encodings together). To enable this behaviour set :multiple to the multiples of characters needed in the encoded string. e.g. A value of 1 (the default) will not require any padding, a value of 2 will require padding if there is only an odd number of characters.

By default the encoded string padding will use 0 bytes, if a specific padding character(s) is desired, this can be done by setting the :pad_chr option to the string to use as the padding sequence (note that only the part of the character sequence needed to reach the specified multiple will be used).

iex> ResxBase.encode16_lower(<<0::size(4)>>)
"0"

iex> ResxBase.encode16_lower(<<0::size(4)>>, multiple: 2, pad_chr: "\a")
"0\a"

iex> ResxBase.encode16_lower(<<0, 0>>)
"0000"
Link to this function

encode16_upper(data, opts \\ [], encoding \\ "")
encode16_upper(bitstring(), Itsy.Binary.encode_options(), binary()) :: binary()

Encodes data into a string which can be decoded using the decode16_upper/3 function.

The encoded data will pad any bits needed to make the entire data fit within byte boundaries. By default this padding will be using 0 bits, however this can be changed by setting the option :pad_bit to the specific bit sequence desired (note that only the part of the bit sequence needed to reach a byte boundary will be used).

Optionally an encoded string can have additional padding put onto the final encoding (e.g. if you wanted to pack encodings together). To enable this behaviour set :multiple to the multiples of characters needed in the encoded string. e.g. A value of 1 (the default) will not require any padding, a value of 2 will require padding if there is only an odd number of characters.

By default the encoded string padding will use 0 bytes, if a specific padding character(s) is desired, this can be done by setting the :pad_chr option to the string to use as the padding sequence (note that only the part of the character sequence needed to reach the specified multiple will be used).

iex> ResxBase.encode16_upper(<<0::size(4)>>)
"0"

iex> ResxBase.encode16_upper(<<0::size(4)>>, multiple: 2, pad_chr: "\a")
"0\a"

iex> ResxBase.encode16_upper(<<0, 0>>)
"0000"
Link to this function

encode32(data, opts \\ [], encoding \\ "")

Encodes data into a string which can be decoded using the decode32/3 function.

The encoded data will pad any bits needed to make the entire data fit within byte boundaries. By default this padding will be using 0 bits, however this can be changed by setting the option :pad_bit to the specific bit sequence desired (note that only the part of the bit sequence needed to reach a byte boundary will be used).

Optionally an encoded string can have additional padding put onto the final encoding (e.g. if you wanted to pack encodings together). To enable this behaviour set :multiple to the multiples of characters needed in the encoded string. e.g. A value of 1 (the default) will not require any padding, a value of 2 will require padding if there is only an odd number of characters.

By default the encoded string padding will use 0 bytes, if a specific padding character(s) is desired, this can be done by setting the :pad_chr option to the string to use as the padding sequence (note that only the part of the character sequence needed to reach the specified multiple will be used).

iex> ResxBase.encode32(<<0::size(5)>>)
"A"

iex> ResxBase.encode32(<<0::size(5)>>, multiple: 8, pad_chr: "\a")
"A\a\a\a\a\a\a\a"

iex> ResxBase.encode32(<<0, 0, 0::size(4)>>)
"AAAA"
Link to this function

encode64(data, opts \\ [], encoding \\ "")

Encodes data into a string which can be decoded using the decode64/3 function.

The encoded data will pad any bits needed to make the entire data fit within byte boundaries. By default this padding will be using 0 bits, however this can be changed by setting the option :pad_bit to the specific bit sequence desired (note that only the part of the bit sequence needed to reach a byte boundary will be used).

Optionally an encoded string can have additional padding put onto the final encoding (e.g. if you wanted to pack encodings together). To enable this behaviour set :multiple to the multiples of characters needed in the encoded string. e.g. A value of 1 (the default) will not require any padding, a value of 2 will require padding if there is only an odd number of characters.

By default the encoded string padding will use 0 bytes, if a specific padding character(s) is desired, this can be done by setting the :pad_chr option to the string to use as the padding sequence (note that only the part of the character sequence needed to reach the specified multiple will be used).

iex> ResxBase.encode64(<<0::size(6)>>)
"A"

iex> ResxBase.encode64(<<0::size(6)>>, multiple: 4, pad_chr: "\a")
"A\a\a\a"

iex> ResxBase.encode64(<<0, 0, 0>>)
"AAAA"
Link to this function

hex_decode32(encoding, opts \\ [], data \\ <<>>)
hex_decode32(bitstring(), Itsy.Binary.decode_options(), bitstring()) ::
  {:ok, bitstring()} | :error

Decodes encoded strings produced by the hex_encode32/3 function.

By default the decoded data will be stripped of any bits that do not fit in the byte boundaries. This behaviour can be changed by setting the :bits option to true. The resulting bitstring may contain some pad bits.

If the encoded string contains some padding characters these will to be specified so they can be removed. Set the :pad_chr option to the padding sequence that was used when encoding this data. Multiple encoded strings with the same padding sequence can be chained together, and will be decoded into a contiguous set of data.

iex> ResxBase.hex_decode32("0")
{ :ok, "" }

iex> ResxBase.hex_decode32("0", bits: true)
{ :ok, <<0::size(5)>> }

iex> ResxBase.hex_decode32("0\a\a\a\a\a\a\a", bits: true, pad_chr: "\a")
{ :ok, <<0::size(5)>> }

iex> ResxBase.hex_decode32("0000", bits: true)
{ :ok, <<0, 0, 0::size(4)>> }
Link to this function

hex_encode32(data, opts \\ [], encoding \\ "")
hex_encode32(bitstring(), Itsy.Binary.encode_options(), binary()) :: binary()

Encodes data into a string which can be decoded using the hex_decode32/3 function.

The encoded data will pad any bits needed to make the entire data fit within byte boundaries. By default this padding will be using 0 bits, however this can be changed by setting the option :pad_bit to the specific bit sequence desired (note that only the part of the bit sequence needed to reach a byte boundary will be used).

Optionally an encoded string can have additional padding put onto the final encoding (e.g. if you wanted to pack encodings together). To enable this behaviour set :multiple to the multiples of characters needed in the encoded string. e.g. A value of 1 (the default) will not require any padding, a value of 2 will require padding if there is only an odd number of characters.

By default the encoded string padding will use 0 bytes, if a specific padding character(s) is desired, this can be done by setting the :pad_chr option to the string to use as the padding sequence (note that only the part of the character sequence needed to reach the specified multiple will be used).

iex> ResxBase.hex_encode32(<<0::size(5)>>)
"0"

iex> ResxBase.hex_encode32(<<0::size(5)>>, multiple: 8, pad_chr: "\a")
"0\a\a\a\a\a\a\a"

iex> ResxBase.hex_encode32(<<0, 0, 0::size(4)>>)
"0000"
Link to this function

url_decode64(encoding, opts \\ [], data \\ <<>>)
url_decode64(bitstring(), Itsy.Binary.decode_options(), bitstring()) ::
  {:ok, bitstring()} | :error

Decodes encoded strings produced by the url_encode64/3 function.

By default the decoded data will be stripped of any bits that do not fit in the byte boundaries. This behaviour can be changed by setting the :bits option to true. The resulting bitstring may contain some pad bits.

If the encoded string contains some padding characters these will to be specified so they can be removed. Set the :pad_chr option to the padding sequence that was used when encoding this data. Multiple encoded strings with the same padding sequence can be chained together, and will be decoded into a contiguous set of data.

iex> ResxBase.url_decode64("A")
{ :ok, "" }

iex> ResxBase.url_decode64("A", bits: true)
{ :ok, <<0::size(6)>> }

iex> ResxBase.url_decode64("A\a\a\a", bits: true, pad_chr: "\a")
{ :ok, <<0::size(6)>> }

iex> ResxBase.url_decode64("AAAA", bits: true)
{ :ok, <<0, 0, 0>> }
Link to this function

url_encode64(data, opts \\ [], encoding \\ "")
url_encode64(bitstring(), Itsy.Binary.encode_options(), binary()) :: binary()

Encodes data into a string which can be decoded using the url_decode64/3 function.

The encoded data will pad any bits needed to make the entire data fit within byte boundaries. By default this padding will be using 0 bits, however this can be changed by setting the option :pad_bit to the specific bit sequence desired (note that only the part of the bit sequence needed to reach a byte boundary will be used).

Optionally an encoded string can have additional padding put onto the final encoding (e.g. if you wanted to pack encodings together). To enable this behaviour set :multiple to the multiples of characters needed in the encoded string. e.g. A value of 1 (the default) will not require any padding, a value of 2 will require padding if there is only an odd number of characters.

By default the encoded string padding will use 0 bytes, if a specific padding character(s) is desired, this can be done by setting the :pad_chr option to the string to use as the padding sequence (note that only the part of the character sequence needed to reach the specified multiple will be used).

iex> ResxBase.url_encode64(<<0::size(6)>>)
"A"

iex> ResxBase.url_encode64(<<0::size(6)>>, multiple: 4, pad_chr: "\a")
"A\a\a\a"

iex> ResxBase.url_encode64(<<0, 0, 0>>)
"AAAA"