Giter Site home page Giter Site logo

hexate's Introduction

Hexate

Build Status Hex.pm Hex.pm

A simple module for hexadecimal encoding / decoding in Elixir.

Note: name change from hex to hexate

Now that Elixir includes integration with Hex.pm, the library has been renamed hexate to avoid namespace clashes.

This was manifesting itself with intermittent failures when running test suites. If you experience this, update your deps!

If you really must use the old version, it's on the branch pre-rename-to-hexate.

Adding to your mix.exs

defp deps do
  [
    {:hexate,  ">= 0.6.0"}
  ]
end

Usage

Encode to string (binary):

# From a string
iex> Hexate.encode("This is a test.")
     "54686973206973206120746573742e"

# From a char-list
iex> Hexate.encode('This is a test.')
     "54686973206973206120746573742e"

iex> Hexate.encode(123456)
     "1e240"

iex> Hexate.encode(15, 4)
     "000f"

iex> Hexate.encode(15.0, 2)
     "0f"

iex> Hexate.encode(15.0)
     "f"

Decode to string (binary):

# From a hex string
iex> Hexate.decode("54686973206973206120746573742e")
     "This is a test."

# From a hex char-list
iex> Hexate.decode('54686973206973206120746573742e')
     "This is a test."

Encode to hex char-list:

# From a unicode char-list
iex> Hexate.encode_to_list('This is a test.')
     '54686973206973206120746573742e'

# From a unicode string
iex> Hexate.encode_to_list("This is a test.")
     '54686973206973206120746573742e'

# From an integer
iex> Hexate.encode_to_list(123456)
     '1e240'

Decode to unicode char-list:

# From a hex char-list
iex> Hexate.decode_to_list('54686973206973206120746573742e')
     'This is a test.'

# From a hex string
iex> Hexate.decode_to_list("54686973206973206120746573742e")
     'This is a test.'

Convert hex to integer:

# From hex char-list
iex> Hexate.to_integer('54686973206973206120746573742e')
     438270661302729020147902120434299950

# From hex string
iex> Hexate.to_integer("54686973206973206120746573742e")
     438270661302729020147902120434299950

Contributing

  • Fork this repo
  • Make a feature branch
  • Issue a pull request

Running tests

mix deps.get
mix test.watch

Authors

Robert J Samson David Parry

hexate's People

Contributors

cgorshing avatar mkb avatar pma avatar rjsamson avatar suranyami avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.