Merge pull request #166 from ariel-anieli/pr-typo-checksums-ec_file
[src/ec_file.erl] Factorization & typos, in sha1sum/1 & md5sum/1
This commit is contained in:
commit
952a1d2bc6
1 changed files with 10 additions and 7 deletions
|
@ -139,24 +139,27 @@ try_write_owner(To, #file_info{uid=OwnerId}) ->
|
||||||
try_write_group(To, #file_info{gid=OwnerId}) ->
|
try_write_group(To, #file_info{gid=OwnerId}) ->
|
||||||
file:write_file_info(To, #file_info{gid=OwnerId}).
|
file:write_file_info(To, #file_info{gid=OwnerId}).
|
||||||
|
|
||||||
%% @doc return an md5 checksum string or a binary. Same as unix utility of
|
%% @doc return the MD5 digest of a string or a binary,
|
||||||
%% same name.
|
%% named after the UNIX utility.
|
||||||
-spec md5sum(string() | binary()) -> string().
|
-spec md5sum(string() | binary()) -> string().
|
||||||
md5sum(Value) ->
|
md5sum(Value) ->
|
||||||
hex(binary_to_list(erlang:md5(Value))).
|
bin_to_hex(erlang:md5(Value)).
|
||||||
|
|
||||||
%% @doc return an sha1sum checksum string or a binary. Same as unix utility of
|
%% @doc return the SHA-1 digest of a string or a binary,
|
||||||
%% same name.
|
%% named after the UNIX utility.
|
||||||
-ifdef(deprecated_crypto).
|
-ifdef(deprecated_crypto).
|
||||||
-spec sha1sum(string() | binary()) -> string().
|
-spec sha1sum(string() | binary()) -> string().
|
||||||
sha1sum(Value) ->
|
sha1sum(Value) ->
|
||||||
hex(binary_to_list(crypto:sha(Value))).
|
bin_to_hex(crypto:sha(Value)).
|
||||||
-else.
|
-else.
|
||||||
-spec sha1sum(string() | binary()) -> string().
|
-spec sha1sum(string() | binary()) -> string().
|
||||||
sha1sum(Value) ->
|
sha1sum(Value) ->
|
||||||
hex(binary_to_list(crypto:hash(sha, Value))).
|
bin_to_hex(crypto:hash(sha, Value)).
|
||||||
-endif.
|
-endif.
|
||||||
|
|
||||||
|
bin_to_hex(Bin) ->
|
||||||
|
hex(binary_to_list(Bin)).
|
||||||
|
|
||||||
%% @doc delete a file. Use the recursive option for directories.
|
%% @doc delete a file. Use the recursive option for directories.
|
||||||
%% <pre>
|
%% <pre>
|
||||||
%% Example: remove("./tmp_dir", [recursive]).
|
%% Example: remove("./tmp_dir", [recursive]).
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue