-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: elixir | ||
elixir: | ||
- 1.8 | ||
env: | ||
- MIX_ENV=test | ||
script: | ||
- mix test | ||
after_success: | ||
- bash <(curl -s https://codecov.io/bash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
# elixir-base58-encode | ||
https://hex.pm/packages/b58 | ||
|
||
|
||
This module provide the `encode/1` function which takes a binary and returns | ||
its base58 representation | ||
|
||
1. Add the package to you dependencies | ||
|
||
``` | ||
defp deps do | ||
[b58: "~> 0.1.0"] | ||
end | ||
``` | ||
|
||
and run `mix deps.get` | ||
|
||
2. Call the `encode` fundtion with a binary as parameter: | ||
|
||
``` | ||
> Base58Encode.encode("foo") | ||
> "bQbp" | ||
``` | ||
|
||
if the parameter is not a binary the function will return `:error` | ||
|
||
``` | ||
> Base58Encode.encode(42) | ||
> "bQbp" | ||
``` | ||
|
||
The alphabet used for base58 is: | ||
`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz` | ||
|
||
For more information about the implementation of this module see the issue 1: | ||
[How to encode a string to base58](https://github.com/dwyl/base58encode/issues/1) | ||
|
||
Read the following for more information about binary in Elixir: | ||
https://elixir-lang.org/getting-started/binaries-strings-and-char-lists.html | ||
|
||
Wikipedia page for base58: | ||
https://en.wikipedia.org/wiki/Base56 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
defmodule Base58EncodeTest do | ||
use ExUnit.Case | ||
doctest Base58Encode | ||
|
||
describe "Testing encode function" do | ||
test "returns base58 for the string foo" do | ||
assert "bQbp" == Base58Encode.encode("foo") | ||
end | ||
|
||
test "returns error if parameter is not a binary" do | ||
assert :error == Base58Encode.encode(23) | ||
end | ||
|
||
test "returns z when binary is represented by 57" do | ||
assert "z" == Base58Encode.encode(<<57>>) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ExUnit.start() |