1: -module(mongoose_bin_SUITE). 2: -compile([export_all, nowarn_export_all]). 3: 4: -include_lib("proper/include/proper.hrl"). 5: -import(prop_helper, [prop/2]). 6: 7: all() -> 8: [ sanity_check, 9: always_produces_well_formed_output 10: ]. 11: 12: sanity_check(_) -> 13: %% @doc vis: echo -n "Foo" | sha256sum 14: Encoded = mongoose_bin:encode_crypto(<<"Foo">>), 15: <<"201a6b3053cc1422d2c3670b62616221d2290929">> = Encoded. 16: 17: always_produces_well_formed_output(_) -> 18: prop(always_produces_well_formed_output, 19: ?FORALL(BinaryBlob, binary(), 20: true == is_well_formed(mongoose_bin:encode_crypto(BinaryBlob)))). 21: 22: is_well_formed(Binary) -> 23: true =:= is_binary(Binary) andalso 24: 40 =:= byte_size(Binary) andalso 25: nomatch == re:run(Binary, "[^0-9a-f]").