Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated ^^^ with Bitwise.bxor #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/bech32.ex
Original file line number Diff line number Diff line change
@@ -48,9 +48,9 @@ defmodule Bech32 do
defp polymod(values) when is_list(values) do
values |> Enum.reduce(1, fn v, chk ->
b = (chk >>> 25)
chk = ((chk &&& 0x1ffffff) <<< 5) ^^^ v
chk = Bitwise.bxor(((chk &&& 0x1ffffff) <<< 5), v)
0..4 |> Enum.reduce(chk, fn i, chk ->
chk ^^^ (if ((b >>> i) &&& 1) !== 0, do: @gen |> elem(i), else: 0)
Bitwise.bxor(chk, (if ((b >>> i) &&& 1) !== 0, do: @gen |> elem(i), else: 0))
end)
end)
end
@@ -153,7 +153,7 @@ defmodule Bech32 do
def create_checksum(hrp, data) when is_binary(hrp) and is_binary(data) do
data = :erlang.binary_to_list(data)
values = hrp_expand(hrp) ++ data
pmod = polymod(values ++ [0,0,0,0,0,0]) ^^^ 1
pmod = Bitwise.bxor(polymod(values ++ [0,0,0,0,0,0]), 1)
(for i <- 0..5, do: (pmod >>> 5 * (5 - i)) &&& 31) |> :erlang.list_to_binary()
end