Adding sha1sum method
This commit is contained in:
parent
364726c166
commit
73f21ee770
1 changed files with 10 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
remove/1,
|
remove/1,
|
||||||
remove/2,
|
remove/2,
|
||||||
md5sum/1,
|
md5sum/1,
|
||||||
|
sha1sum/1,
|
||||||
read/1,
|
read/1,
|
||||||
write/2,
|
write/2,
|
||||||
write_term/2
|
write_term/2
|
||||||
|
@ -90,6 +91,12 @@ copy(From, To) ->
|
||||||
-spec md5sum(string() | binary()) -> string().
|
-spec md5sum(string() | binary()) -> string().
|
||||||
md5sum(Value) ->
|
md5sum(Value) ->
|
||||||
hex(binary_to_list(erlang:md5(Value))).
|
hex(binary_to_list(erlang:md5(Value))).
|
||||||
|
|
||||||
|
%% @doc return an sha1sum checksum string or a binary. Same as unix utility of
|
||||||
|
%% same name.
|
||||||
|
-spec sha1sum(string() | binary()) -> string().
|
||||||
|
sha1sum(Value) ->
|
||||||
|
hex(binary_to_list(crypto:hash(sha, Value))).
|
||||||
|
|
||||||
%% @doc delete a file. Use the recursive option for directories.
|
%% @doc delete a file. Use the recursive option for directories.
|
||||||
%% <pre>
|
%% <pre>
|
||||||
|
@ -312,6 +319,9 @@ setup_test() ->
|
||||||
|
|
||||||
md5sum_test() ->
|
md5sum_test() ->
|
||||||
?assertMatch("cfcd208495d565ef66e7dff9f98764da", md5sum("0")).
|
?assertMatch("cfcd208495d565ef66e7dff9f98764da", md5sum("0")).
|
||||||
|
|
||||||
|
sha1sum_test() ->
|
||||||
|
?assertMatch("b6589fc6ab0dc82cf12099d1c2d40ab994e8410c", sha1sum("0")).
|
||||||
|
|
||||||
file_test() ->
|
file_test() ->
|
||||||
Dir = insecure_mkdtemp(),
|
Dir = insecure_mkdtemp(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue