Erlang - checksum
God's morning
I am trying to perform a checksum on the following function
Data = [<<"9">>,"81",
<<1>>,
<<"52=">>,
[[50,48,49,48,49,48,50,54,45,49,53,":",52,53,":",52,52]],
<<1>>,
<<1>>,
[<<"9">>,<<"0">>,<<1>>],
[<<"5">>,<<"4">>,<<1>>]]
Using:
checksum(Data) -> checksum(Data, 0).
checksum([H | T], Acc) ->
if
is_binary(H) ->
I = binary_to_list(H);
true ->
I = H
end,
checksum(T, I + Acc);
checksum([], Acc) -> Acc.
Basically, you need to break the data into discrete numbers
ideally, it would look like [56,45,34,111,233, ...]
and then add them all together.
The compiler gives me errors no matter what I try. I decided this before it was very simple, but now one change in the food chain has affected it.
Please help, and best wishes!
CRC, CRC32 Adler-32 erlang: crc32 erlang: adler32 BIF:
1> Data = [<<"9">>,"81",
1> <<1>>,
1> <<"52=">>,
1> [[50,48,49,48,49,48,50,54,45,49,53,":",52,53,":",52,52]],
1> <<1>>,
1> <<1>>,
1> [<<"9">>,<<"0">>,<<1>>],
1> [<<"5">>,<<"4">>,<<1>>]]
1> .
[<<"9">>,"81",
<<1>>,
<<"52=">>,
[[50,48,49,48,49,48,50,54,45,49,53,":",52,53,":",52,52]],
<<1>>,
<<1>>,
[<<"9">>,<<"0">>,<<1>>],
[<<"5">>,<<"4">>,<<1>>]]
2> erlang:adler32(Data).
1636173186
3> erlang:crc32(Data).
3649492735
erlang: phash2 BIF:
4> erlang:phash2(Data).
38926910
5> erlang:phash2(Data, 65536).
64062