Packages

Efficient implementation of z-base-32, Phil Zimmermann's human-oriented base-32 encoding.

Current section

3 Versions

Jump to

Compare versions

4 files changed
+23 additions
-17 deletions
  @@ -1,5 +1,7 @@
1 1 # ZBase32
2 2
3 + [<img src="http://quickcheck-ci.com/p/pspdfkit-labs/zbase32.svg" alt="Build Status" width="130px">](http://quickcheck-ci.com/p/pspdfkit-labs/zbase32)
4 +
3 5 Efficient implementation of [z-base-32](https://en.wikipedia.org/wiki/Base32#z-base-32), Phil
4 6 Zimmermann's [human-oriented base-32 encoding](http://philzimmermann.com/docs/human-oriented-base-32-encoding.txt).
  @@ -1,7 +1,7 @@
1 1 {<<"app">>,<<"zbase32">>}.
2 2 {<<"build_tools">>,[<<"mix">>]}.
3 3 {<<"description">>,
4 - <<"Efficient implementation of z-base-32, Phil Zimmermann's human-oriented base-32 encoding.\n\nz-base-32 is a Base32 encoding designed to be easier for human use and more compact. It includes\n1, 8 and 9 but excludes l, v and 2. It also permutes the alphabet so that the easier characters\nare the ones that occur more frequently. It compactly encodes bitstrings whose length in bits is\nnot a multiple of 8, and omits trailing padding characters. z-base-32 was used in Mnet open\nsource project, and is currently used in Phil Zimmermann's ZRTP protocol, and in the Tahoe-LAFS\nopen source project.">>}.
4 + <<"Efficient implementation of z-base-32, Phil Zimmermann's human-oriented base-32 encoding.">>}.
5 5 {<<"elixir">>,<<"~> 1.0">>}.
6 6 {<<"files">>,
7 7 [<<"lib/zbase32.ex">>,<<"mix.exs">>,<<"README.md">>,<<"LICENSE">>]}.
  @@ -10,4 +10,4 @@
10 10 {<<"maintainers">>,[<<"pspdfkit.com">>]}.
11 11 {<<"name">>,<<"zbase32">>}.
12 12 {<<"requirements">>,[]}.
13 - {<<"version">>,<<"1.0.0">>}.
13 + {<<"version">>,<<"1.0.1">>}.
  @@ -6,6 +6,10 @@ defmodule ZBase32 do
6 6 """
7 7 use Bitwise
8 8
9 + @doc ~S"""
10 + Encodes a binary string into a z-base-32 encoded string.
11 + """
12 + @spec encode(binary) :: String.t
9 13 def encode(<<>>), do: <<>>
10 14 def encode(data) when is_binary(data) do
11 15 split = 5 * div(byte_size(data), 5)
  @@ -35,6 +39,10 @@ defmodule ZBase32 do
35 39 end
36 40 end
37 41
42 + @doc ~S"""
43 + Decodes a z-base-32 encoded string into a binary string.
44 + """
45 + @spec decode(String.t) :: binary
38 46 def decode(<<>>), do: <<>>
39 47 def decode(string) when is_binary(string) do
40 48 split = byte_size(string) - rem(byte_size(string), 8)
  @@ -3,13 +3,16 @@ defmodule Zbase32.Mixfile do
3 3
4 4 def project do
5 5 [app: :zbase32,
6 - version: "1.0.0",
6 + version: "1.0.1",
7 + name: "ZBase32",
8 + source_url: "https://github.com/pspdfkit-labs/zbase32",
9 + docs: [extras: ["README.md"]],
7 10 elixir: "~> 1.0",
8 11 build_embedded: Mix.env == :prod,
9 12 start_permanent: Mix.env == :prod,
10 - description: description,
11 - package: package,
12 - deps: deps]
13 + description: description(),
14 + package: package(),
15 + deps: deps()]
13 16 end
14 17
15 18 def application do
  @@ -18,21 +21,14 @@ defmodule Zbase32.Mixfile do
18 21
19 22 defp deps do
20 23 [
21 - {:eqc_ex, "~> 1.2.3", only: :test}
24 + {:earmark, "> 0.0.0", only: :dev},
25 + {:eqc_ex, "> 0.0.0", only: :test},
26 + {:ex_doc, "> 0.0.0", only: :dev},
22 27 ]
23 28 end
24 29
25 30 defp description do
26 - """
27 - Efficient implementation of z-base-32, Phil Zimmermann's human-oriented base-32 encoding.
28 -
29 - z-base-32 is a Base32 encoding designed to be easier for human use and more compact. It includes
30 - 1, 8 and 9 but excludes l, v and 2. It also permutes the alphabet so that the easier characters
31 - are the ones that occur more frequently. It compactly encodes bitstrings whose length in bits is
32 - not a multiple of 8, and omits trailing padding characters. z-base-32 was used in Mnet open
33 - source project, and is currently used in Phil Zimmermann's ZRTP protocol, and in the Tahoe-LAFS
34 - open source project.
35 - """
31 + "Efficient implementation of z-base-32, Phil Zimmermann's human-oriented base-32 encoding."
36 32 end
37 33
38 34 defp package do